Files
aitbc/tests/conftest.py
aitbc 40cee6d791
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
Documentation Validation / validate-policies-strict (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
API Endpoint Tests / test-api-endpoints (push) Successful in 20s
CLI Tests / test-cli (push) Failing after 3s
Package Tests / Python package - aitbc-agent-sdk (push) Successful in 33s
Package Tests / Python package - aitbc-core (push) Failing after 1s
Package Tests / Python package - aitbc-crypto (push) Successful in 10s
Package Tests / Python package - aitbc-sdk (push) Successful in 9s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 10s
Package Tests / JavaScript package - aitbc-token (push) Successful in 17s
Production Tests / Production Integration Tests (push) Failing after 6s
refactor: enhance configuration with security validation, database pooling, and rate limiting
- Added List import and field_validator to config.py
- Added database connection pooling settings (max_overflow, pool_recycle, pool_pre_ping, echo)
- Added rate limiting settings (rate_limit_requests, rate_limit_window_seconds)
- Added CORS allow_origins field with default empty list
- Added validate_secrets() method to check required secrets in production
- Added validate_secret_length() validator for secret_key and jwt_secret (minimum
2026-05-12 21:17:54 +02:00

133 lines
3.3 KiB
Python

"""
Minimal conftest for pytest discovery
Imports fixtures from dedicated fixture files for better organization
"""
import sys
from pathlib import Path
# Configure Python path for test discovery
project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root))
# Import fixtures from dedicated fixture files
# Common fixtures (environment setup, data generators)
from tests.fixtures.common import (
setup_test_environment,
mock_optional_dependencies,
mock_aitbc_crypto,
sample_tenant,
sample_job_data,
mock_db,
mock_cache,
test_user_data,
test_transaction_data,
test_wallet_data,
test_ethereum_address,
)
# Coordinator API fixtures
from tests.fixtures.coordinator import coordinator_client
# Blockchain fixtures
from tests.fixtures.blockchain import (
blockchain_client,
wallet_client,
marketplace_client,
)
# Training fixtures (kept here as they're specific to training tests)
from aitbc.training_setup import TrainingEnvironment, TrainingSetupError
# Auth fixtures
from tests.fixtures.auth_fixtures import (
mock_jwt_secret,
test_user_token,
test_admin_token,
expired_token,
invalid_token,
auth_headers,
admin_auth_headers,
mock_user,
mock_admin_user,
mock_auth_service,
permission_checker,
api_key_headers,
mock_api_keys,
)
# Test data factory
from tests.fixtures.test_data_factory import TestDataFactory
import pytest
@pytest.fixture(scope="session")
def training_env():
"""
Session-scoped fixture for training environment setup.
Sets up the training environment once per test session.
"""
env = TrainingEnvironment()
try:
env.check_prerequisites()
yield env
except TrainingSetupError as e:
pytest.skip(f"Training prerequisites not met: {e}")
@pytest.fixture
def training_env_mock():
"""
Function-scoped fixture for mocked training environment.
Uses mocked subprocess calls for faster, isolated tests.
"""
from unittest.mock import patch, MagicMock
env = TrainingEnvironment()
def mock_subprocess_run(*args, **kwargs):
mock_result = MagicMock()
mock_result.returncode = 0
mock_result.stdout = "success"
mock_result.stderr = ""
return mock_result
with patch('subprocess.run', side_effect=mock_subprocess_run):
yield env
@pytest.fixture
def mock_faucet_response():
"""Mock faucet API response for testing"""
return {
"status": "success",
"address": "ait1testaddress",
"amount": 1000,
"transaction_id": "tx_test123",
"timestamp": "2026-05-05T12:00:00"
}
@pytest.fixture
def training_stage_data():
"""Sample training stage data for testing"""
return {
"stage": "stage1_foundation",
"agent_type": "general",
"training_data": {
"prerequisites": {
"description": "Test prerequisites",
"setup_script": "/opt/aitbc/scripts/training/setup_training_env.sh",
"requirements": ["AITBC node running", "Funded accounts"]
},
"operations": [
{
"operation": "wallet_create",
"parameters": {"name": "test-wallet"},
"expected_result": {"status": "success"}
}
]
}
}