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
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:
6
tests/fixtures/staking_fixtures.py
vendored
6
tests/fixtures/staking_fixtures.py
vendored
@@ -3,15 +3,17 @@ Shared fixtures for staking tests
|
|||||||
Reusable fixtures for service and integration tests to avoid duplication
|
Reusable fixtures for service and integration tests to avoid duplication
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
import pytest
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker, Session
|
from sqlalchemy.orm import sessionmaker, Session
|
||||||
from sqlmodel import SQLModel
|
from sqlmodel import SQLModel
|
||||||
|
|
||||||
# Add paths for imports
|
# 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 (
|
from app.domain.bounty import (
|
||||||
AgentStake, AgentMetrics, StakingPool,
|
AgentStake, AgentMetrics, StakingPool,
|
||||||
|
|||||||
@@ -3,13 +3,16 @@ Staking Lifecycle Integration Tests
|
|||||||
Test 3.1.1: Complete staking lifecycle integration test
|
Test 3.1.1: Complete staking lifecycle integration test
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
sys.path.insert(0, "/opt/aitbc/apps/coordinator-api/src")
|
import pytest
|
||||||
sys.path.insert(0, "/opt/aitbc/contracts")
|
|
||||||
|
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
|
# Import after path setup
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
|
|||||||
@@ -3,15 +3,16 @@ Staking Service Tests
|
|||||||
High-priority tests for staking service functionality
|
High-priority tests for staking service functionality
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
import pytest
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker, Session
|
from sqlalchemy.orm import sessionmaker, Session
|
||||||
|
|
||||||
import sys
|
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "apps/coordinator-api/src"))
|
||||||
sys.path.insert(0, "/opt/aitbc/apps/coordinator-api/src")
|
|
||||||
|
|
||||||
from app.domain.bounty import AgentStake, AgentMetrics, StakingPool, StakeStatus, PerformanceTier
|
from app.domain.bounty import AgentStake, AgentMetrics, StakingPool, StakeStatus, PerformanceTier
|
||||||
from app.services.staking_service import StakingService
|
from app.services.staking_service import StakingService
|
||||||
|
|||||||
Reference in New Issue
Block a user