FREDML / backup /redundant_files /test_analytics_fix.py
Edwin Salguero
Enhanced FRED ML with improved Reports & Insights page, fixed alignment analysis, and comprehensive analytics improvements
2469150
#!/usr/bin/env python3
"""
Test script to verify analytics are loading after config fix
"""
import sys
import os
# Add the project root to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
def test_config_import():
"""Test if config.settings can be imported"""
print("πŸ” Testing config.settings import...")
try:
from config.settings import Config
print("βœ… Config import successful")
return True
except Exception as e:
print(f"❌ Config import failed: {e}")
return False
def test_analytics_import():
"""Test if analytics modules can be imported"""
print("πŸ” Testing analytics import...")
try:
from src.analysis.comprehensive_analytics import ComprehensiveAnalytics
print("βœ… Analytics import successful")
return True
except Exception as e:
print(f"❌ Analytics import failed: {e}")
return False
def test_app_analytics():
"""Test if the app can load analytics"""
print("πŸ” Testing app analytics loading...")
try:
# Import the app's analytics loading function
import frontend.app as app
# Check if analytics are available
if hasattr(app, 'ANALYTICS_AVAILABLE'):
print(f"βœ… Analytics available: {app.ANALYTICS_AVAILABLE}")
return app.ANALYTICS_AVAILABLE
else:
print("❌ ANALYTICS_AVAILABLE not found in app")
return False
except Exception as e:
print(f"❌ App analytics test failed: {e}")
return False
if __name__ == "__main__":
print("πŸ§ͺ Testing Analytics Fix")
print("=" * 50)
config_ok = test_config_import()
analytics_ok = test_analytics_import()
app_analytics_ok = test_app_analytics()
print("\nπŸ“Š Results:")
print(f"Config Import: {'βœ…' if config_ok else '❌'}")
print(f"Analytics Import: {'βœ…' if analytics_ok else '❌'}")
print(f"App Analytics: {'βœ…' if app_analytics_ok else '❌'}")
if config_ok and analytics_ok and app_analytics_ok:
print("\nπŸŽ‰ All tests passed! Analytics should be working.")
else:
print("\n⚠️ Some tests failed. Analytics may not be fully functional.")