Spaces:
Running
Running
#!/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'}!") |