folder stricture reorganize
This commit is contained in:
103
tests/test_dashboard_simple.py
Normal file
103
tests/test_dashboard_simple.py
Normal file
@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple Dashboard Test - Isolate dashboard startup issues
|
||||
"""
|
||||
|
||||
import os
|
||||
# Fix OpenMP library conflicts before importing other modules
|
||||
os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE'
|
||||
os.environ['OMP_NUM_THREADS'] = '4'
|
||||
|
||||
import sys
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
# Add project root to path
|
||||
project_root = Path(__file__).parent
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
# Setup basic logging
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def test_dashboard_startup():
|
||||
"""Test dashboard creation and startup"""
|
||||
try:
|
||||
logger.info("=" * 50)
|
||||
logger.info("TESTING DASHBOARD STARTUP")
|
||||
logger.info("=" * 50)
|
||||
|
||||
# Test imports first
|
||||
logger.info("Step 1: Testing imports...")
|
||||
from core.config import get_config, setup_logging
|
||||
from core.data_provider import DataProvider
|
||||
from core.orchestrator import TradingOrchestrator
|
||||
from core.trading_executor import TradingExecutor
|
||||
logger.info("✓ Core imports successful")
|
||||
|
||||
from web.dashboard import TradingDashboard
|
||||
logger.info("✓ Dashboard import successful")
|
||||
|
||||
# Test configuration
|
||||
logger.info("Step 2: Testing configuration...")
|
||||
setup_logging()
|
||||
config = get_config()
|
||||
logger.info("✓ Configuration loaded")
|
||||
|
||||
# Test core component creation
|
||||
logger.info("Step 3: Testing core component creation...")
|
||||
data_provider = DataProvider()
|
||||
logger.info("✓ DataProvider created")
|
||||
|
||||
orchestrator = TradingOrchestrator(data_provider=data_provider)
|
||||
logger.info("✓ TradingOrchestrator created")
|
||||
|
||||
trading_executor = TradingExecutor()
|
||||
logger.info("✓ TradingExecutor created")
|
||||
|
||||
# Test dashboard creation
|
||||
logger.info("Step 4: Testing dashboard creation...")
|
||||
dashboard = TradingDashboard(
|
||||
data_provider=data_provider,
|
||||
orchestrator=orchestrator,
|
||||
trading_executor=trading_executor
|
||||
)
|
||||
logger.info("✓ TradingDashboard created successfully")
|
||||
|
||||
# Test dashboard startup
|
||||
logger.info("Step 5: Testing dashboard server startup...")
|
||||
logger.info("Dashboard will start on http://127.0.0.1:8052")
|
||||
logger.info("Press Ctrl+C to stop the test")
|
||||
|
||||
# Run the dashboard
|
||||
dashboard.app.run(
|
||||
host='127.0.0.1',
|
||||
port=8052,
|
||||
debug=False,
|
||||
use_reloader=False
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"❌ Dashboard test failed: {e}")
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
success = test_dashboard_startup()
|
||||
if success:
|
||||
logger.info("✓ Dashboard test completed successfully")
|
||||
else:
|
||||
logger.error("❌ Dashboard test failed")
|
||||
sys.exit(1)
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Dashboard test interrupted by user")
|
||||
except Exception as e:
|
||||
logger.error(f"Fatal error in dashboard test: {e}")
|
||||
sys.exit(1)
|
Reference in New Issue
Block a user