#!/usr/bin/env python3 """ Test that the application can start up without errors """ def test_app_imports(): """Test that all required modules can be imported""" print("๐Ÿงช Testing Application Imports\n") try: from core_classes import AIClientManager print(" โœ… AIClientManager imported successfully") except Exception as e: print(f" โŒ AIClientManager import error: {e}") return False try: from lifestyle_app import ExtendedLifestyleJourneyApp print(" โœ… ExtendedLifestyleJourneyApp imported successfully") except Exception as e: print(f" โŒ ExtendedLifestyleJourneyApp import error: {e}") return False return True def test_app_initialization(): """Test that the app can be initialized""" print("\n๐Ÿฅ **Testing Application Initialization:**") try: from lifestyle_app import ExtendedLifestyleJourneyApp app = ExtendedLifestyleJourneyApp() print(" โœ… App initialized successfully") # Test that API manager is properly set up if hasattr(app, 'api') and hasattr(app.api, 'call_counter'): print(f" โœ… API manager ready (call_counter: {app.api.call_counter})") else: print(" โŒ API manager not properly initialized") return False return True except Exception as e: print(f" โŒ App initialization error: {e}") return False def test_status_info(): """Test that _get_status_info works without errors""" print("\n๐Ÿ“Š **Testing Status Info Generation:**") try: from lifestyle_app import ExtendedLifestyleJourneyApp app = ExtendedLifestyleJourneyApp() # This was the problematic method status = app._get_status_info() print(" โœ… Status info generated successfully") print(f" Status length: {len(status)} characters") # Check that it contains expected sections if "AI STATISTICS" in status: print(" โœ… AI statistics section present") else: print(" โš ๏ธ AI statistics section missing") if "AI PROVIDERS STATUS" in status: print(" โœ… AI providers status section present") else: print(" โš ๏ธ AI providers status section missing") return True except Exception as e: print(f" โŒ Status info error: {e}") return False def test_ai_providers_status(): """Test the new AI providers status method""" print("\n๐Ÿค– **Testing AI Providers Status:**") try: from lifestyle_app import ExtendedLifestyleJourneyApp app = ExtendedLifestyleJourneyApp() # Test the new method ai_status = app._get_ai_providers_status() print(" โœ… AI providers status generated successfully") print(f" Status preview: {ai_status[:100]}...") return True except Exception as e: print(f" โŒ AI providers status error: {e}") return False if __name__ == "__main__": print("๐Ÿš€ Application Startup Test Suite") print("=" * 50) success = True success &= test_app_imports() success &= test_app_initialization() success &= test_status_info() success &= test_ai_providers_status() print("\n๐Ÿ“‹ **Summary:**") if success: print(" โœ… All tests passed - application should start successfully") print(" โœ… Backward compatibility maintained") print(" โœ… AI providers integration working") print(" โœ… Status info generation fixed") else: print(" โŒ Some tests failed - check errors above") print(f"\n{'โœ… SUCCESS' if success else 'โŒ FAILURE'}: Application startup test {'passed' if success else 'failed'}!")