Files
aitbc/apps/coordinator-api/tests/conftest.py
aitbc 53fa9768f3
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
feat: add swarm node management and compute cluster endpoints
- Added RegisterNodeRequest, ReportTaskRequest, CreateClusterRequest models
- Implemented POST /nodes/register endpoint for compute node registration
- Implemented POST /nodes/{node_id}/heartbeat endpoint for node health checks
- Implemented GET /nodes endpoint with status and capability filters
- Implemented GET /nodes/{node_id} endpoint for node details
- Implemented POST /tasks/submit endpoint for task submission
- Implemented POST
2026-05-19 10:28:10 +02:00

44 lines
1.4 KiB
Python
Executable File

"""Ensure coordinator-api src is on sys.path for all tests in this directory."""
import sys
import os
import tempfile
from pathlib import Path
import pytest
_src = str(Path(__file__).resolve().parent.parent / "src")
# Remove any stale 'app' module loaded from a different package so the
# coordinator 'app' resolves correctly.
_app_mod = sys.modules.get("app")
if _app_mod and hasattr(_app_mod, "__file__") and _app_mod.__file__ and _src not in str(_app_mod.__file__):
for key in list(sys.modules):
if key == "app" or key.startswith("app."):
del sys.modules[key]
if _src not in sys.path:
sys.path.insert(0, _src)
# Set up test environment
os.environ["TEST_MODE"] = "true"
project_root = Path(__file__).resolve().parent.parent.parent
os.environ["AUDIT_LOG_DIR"] = str(project_root / "logs" / "audit")
os.environ["TEST_DATABASE_URL"] = "sqlite:///:memory:"
@pytest.fixture(scope="function")
def db_session():
"""Create a fresh database session for each test."""
from sqlmodel import SQLModel, create_engine, Session
engine = create_engine("sqlite:///:memory:", echo=False)
SQLModel.metadata.create_all(engine)
with Session(engine) as session:
yield session
@pytest.fixture(scope="function")
def client():
"""Create a TestClient for API testing."""
from fastapi.testclient import TestClient
from app.main import app
return TestClient(app)