refactor: replace hardcoded paths with dynamic Path resolution in staking tests
All checks were successful
Python Tests / test-python (push) Successful in 2m32s
Staking Tests / test-staking-service (push) Successful in 2m17s
Staking Tests / test-staking-integration (push) Successful in 2m23s
Staking Tests / test-staking-contract (push) Successful in 1m16s
Staking Tests / run-staking-test-runner (push) Successful in 2m30s

- Changed from hardcoded /opt/aitbc paths to Path(__file__).resolve().parents[2] for dynamic repository root resolution
- Reorganized imports to follow standard order (stdlib, third-party, local)
- Removed duplicate sys import in test_staking_service.py
- Extracted repo_root variable in test_staking_lifecycle.py for cleaner path construction
This commit is contained in:
aitbc
2026-04-19 20:44:42 +02:00
parent 20b2d2040c
commit 59ae930411
3 changed files with 14 additions and 8 deletions

View File

@@ -3,15 +3,17 @@ Shared fixtures for staking tests
Reusable fixtures for service and integration tests to avoid duplication
"""
import pytest
import sys
from pathlib import Path
from datetime import datetime, timedelta
import pytest
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, Session
from sqlmodel import SQLModel
# Add paths for imports
sys.path.insert(0, "/opt/aitbc/apps/coordinator-api/src")
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "apps/coordinator-api/src"))
from app.domain.bounty import (
AgentStake, AgentMetrics, StakingPool,

View File

@@ -3,13 +3,16 @@ Staking Lifecycle Integration Tests
Test 3.1.1: Complete staking lifecycle integration test
"""
import pytest
import asyncio
import sys
from pathlib import Path
from datetime import datetime, timedelta
sys.path.insert(0, "/opt/aitbc/apps/coordinator-api/src")
sys.path.insert(0, "/opt/aitbc/contracts")
import pytest
repo_root = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(repo_root / "apps/coordinator-api/src"))
sys.path.insert(0, str(repo_root / "contracts"))
# Import after path setup
from sqlalchemy import create_engine

View File

@@ -3,15 +3,16 @@ Staking Service Tests
High-priority tests for staking service functionality
"""
import pytest
import asyncio
import sys
from pathlib import Path
from datetime import datetime, timedelta
import pytest
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, Session
import sys
sys.path.insert(0, "/opt/aitbc/apps/coordinator-api/src")
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "apps/coordinator-api/src"))
from app.domain.bounty import AgentStake, AgentMetrics, StakingPool, StakeStatus, PerformanceTier
from app.services.staking_service import StakingService