Spaces:
Running
Running
File size: 3,932 Bytes
7605012 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
#!/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'}!") |