Files
aitbc/tests/test_hierarchical_config.py
aitbc 9133609603
Some checks failed
Blockchain Synchronization Verification / sync-verification (push) Failing after 7s
CLI Tests / test-cli (push) Failing after 9s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Successful in 3s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 6s
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Successful in 2s
Deploy to Testnet / deploy-testnet (push) Successful in 1m28s
Documentation Validation / validate-docs (push) Failing after 10s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Integration Tests / test-service-integration (push) Failing after 47s
Multi-Chain Island Architecture Tests / test-multi-chain-island (push) Successful in 3s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 2s
Node Failover Simulation / failover-test (push) Failing after 45m25s
P2P Network Verification / p2p-verification (push) Successful in 6s
Package Tests / Python package - aitbc-agent-sdk (push) Successful in 33s
Package Tests / Python package - aitbc-core (push) Successful in 14s
Package Tests / Python package - aitbc-crypto (push) Successful in 9s
Package Tests / Python package - aitbc-sdk (push) Successful in 11s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 8s
Package Tests / JavaScript package - aitbc-token (push) Successful in 16s
Python Tests / test-python (push) Failing after 42s
Security Scanning / security-scan (push) Failing after 35s
Cross-Chain Functionality Tests / aggregate-results (push) Successful in 2s
Multi-Node Stress Testing / stress-test (push) Successful in 5s
Cross-Node Transaction Testing / transaction-test (push) Successful in 3s
refactor: improve security, error handling, and service configuration
- Added PACKAGE_VERSION to aitbc/__init__.py exports
- Added block height validation and duplicate block handling in blockchain-node RPC router
- Added HTTP 409 conflict response for duplicate block heights with different hashes
- Changed certification router to use PartnershipProgramRequest model instead of individual parameters
- Fixed import paths: certification_service -> certification, advanced_reinforcement_learning -> advanced_rl
- Added MarketplaceStrategyOptimizer to advanced_rl module exports
2026-05-12 10:42:48 +02:00

88 lines
2.7 KiB
Python

#!/usr/bin/env python3
"""Test hierarchical config implementation"""
import sys
import os
import tempfile
from pathlib import Path
# Add the aitbc module to path
sys.path.insert(0, '/opt/aitbc')
def test_hierarchical_config():
print("Testing Hierarchical Configuration System...")
try:
from aitbc.hierarchical_config import load_config, ValidatedAITBCConfig, create_config_template
print("✓ Imports successful")
except ImportError as e:
print(f"✗ Import failed: {e}")
return False
# Test 1: Default loading
try:
config = load_config()
print(f"✓ Default config loaded: env={config.environment}, port={config.port}")
except Exception as e:
print(f"✗ Default config failed: {e}")
return False
# Test 2: File-based config
try:
with tempfile.NamedTemporaryFile(mode='w', suffix='.yaml', delete=False) as f:
f.write('''
environment: production
port: 9000
debug: false
log_level: WARNING
secret_key: "test-secret"
jwt_secret: "test-jwt"
''')
temp_path = f.name
config = load_config(config_file=temp_path)
print(f"✓ File config loaded: env={config.environment}, port={config.port}")
os.unlink(temp_path)
except Exception as e:
print(f"✗ File config failed: {e}")
return False
# Test 3: Validation
try:
# Set up for production validation
os.environ['AITBC_ENVIRONMENT'] = 'production'
os.environ['AITBC_SECRET_KEY'] = 'test-key'
os.environ['AITBC_JWT_SECRET'] = 'test-jwt'
config = ValidatedAITBCConfig()
print('✓ Production validation passed')
# Should fail without secrets
del os.environ['AITBC_SECRET_KEY']
try:
config = ValidatedAITBCConfig()
print('✗ Validation should have failed')
return False
except Exception:
print('✓ Validation correctly rejected missing secret')
os.environ['AITBC_SECRET_KEY'] = 'test-key' # restore
except Exception as e:
print(f'✗ Validation test failed: {e}')
return False
# Test 4: Templates
try:
dev = create_config_template('development')
prod = create_config_template('production')
print(f'✓ Templates created: dev_debug={dev["debug"]}, prod_workers={prod["workers"]}')
except Exception as e:
print(f'✗ Template test failed: {e}')
return False
print("✓ All hierarchical config tests passed!")
return True
if __name__ == "__main__":
success = test_hierarchical_config()
sys.exit(0 if success else 1)