Files
aitbc/apps/pool-hub/tests/conftest.py
aitbc e22d864944
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 11s
CLI Tests / test-cli (push) Failing after 7s
Documentation Validation / validate-docs (push) Successful in 8s
Documentation Validation / validate-policies-strict (push) Successful in 3s
Integration Tests / test-service-integration (push) Successful in 38s
Python Tests / test-python (push) Successful in 11s
Security Scanning / security-scan (push) Successful in 29s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 1s
feat: implement CLI blockchain features and pool hub enhancements
CLI Blockchain Features:
- Added block operations: import, export, import-chain, blocks-range
- Added messaging system commands (deploy, state, topics, create-topic, messages, post, vote, search, reputation, moderate)
- Added network force-sync operation
- Replaced marketplace handlers with actual RPC calls
- Replaced AI handlers with actual RPC calls
- Added account operations (account get)
- Added transaction query operations
- Added mempool query operations
- Created keystore_auth.py for authentication
- Removed extended features interception
- All handlers use keystore credentials for authenticated endpoints

Pool Hub Enhancements:
- Added SLA monitoring and capacity tables
- Added billing integration service
- Added SLA collector service
- Added SLA router endpoints
- Updated pool hub models and settings
- Added integration tests for billing and SLA
- Updated documentation with SLA monitoring guide
2026-04-22 15:59:00 +02:00

68 lines
1.8 KiB
Python
Executable File

from __future__ import annotations
import os
import sys
from pathlib import Path
import pytest
import pytest_asyncio
from dotenv import load_dotenv
from redis.asyncio import Redis
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker, create_async_engine
# Load .env file
BASE_DIR = Path(__file__).resolve().parents[2]
load_dotenv(BASE_DIR / ".env")
POOLHUB_SRC = BASE_DIR / "pool-hub" / "src"
if str(POOLHUB_SRC) not in sys.path:
sys.path.insert(0, str(POOLHUB_SRC))
from poolhub.models import Base
def _get_required_env(name: str) -> str:
value = os.getenv(name)
if not value:
pytest.skip(f"Set {name} to run Pool Hub integration tests")
return value
@pytest_asyncio.fixture()
async def db_engine() -> AsyncEngine:
dsn = _get_required_env("POOLHUB_TEST_POSTGRES_DSN")
engine = create_async_engine(dsn, pool_pre_ping=True)
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.drop_all)
await conn.run_sync(Base.metadata.create_all)
yield engine
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.drop_all)
await engine.dispose()
@pytest_asyncio.fixture
async def db_session(db_engine: AsyncEngine) -> AsyncSession:
session_factory = async_sessionmaker(db_engine, expire_on_commit=False, autoflush=False)
async with session_factory() as session:
yield session
await session.rollback()
@pytest_asyncio.fixture()
async def redis_client() -> Redis:
redis_url = _get_required_env("POOLHUB_TEST_REDIS_URL")
client = Redis.from_url(redis_url, encoding="utf-8", decode_responses=True)
await client.flushdb()
yield client
await client.flushdb()
await client.close()
@pytest_asyncio.fixture(autouse=True)
async def _clear_redis(redis_client: Redis) -> None:
await redis_client.flushdb()