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'}!")