File size: 3,295 Bytes
8024c76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Simple Local App Test
Quick test to verify the app is working locally
"""

import requests
import os

def test_app_running():
    """Test if app is running"""
    print("πŸ” Testing if app is running...")
    try:
        response = requests.get("http://localhost:8501/_stcore/health", timeout=5)
        if response.status_code == 200:
            print("βœ… App is running on http://localhost:8501")
            return True
        else:
            print(f"❌ App health check failed: {response.status_code}")
            return False
    except Exception as e:
        print(f"❌ App not accessible: {e}")
        return False

def test_fred_api_key():
    """Test FRED API key configuration"""
    print("πŸ” Testing FRED API key...")
    fred_key = os.getenv('FRED_API_KEY')
    if fred_key and fred_key != "your-fred-api-key-here":
        print("βœ… FRED API key is configured")
        return True
    else:
        print("⚠️ FRED API key not configured (will use demo mode)")
        return False

def test_file_updates():
    """Test that key files have been updated"""
    print("πŸ” Testing file updates...")
    
    # Check version in app.py
    with open("frontend/app.py", "r") as f:
        content = f.read()
        if "VERSION: 2.0.1" in content:
            print("βœ… Version 2.0.1 found in app.py")
        else:
            print("❌ Version 2.0.1 not found in app.py")
            return False
    
    # Check Apache license
    with open("LICENSE", "r") as f:
        content = f.read()
        if "Apache License" in content and "Version 2.0" in content:
            print("βœ… Apache 2.0 license applied")
        else:
            print("❌ Apache 2.0 license not found")
            return False
    
    # Check README
    with open("README.md", "r") as f:
        content = f.read()
        if "FRED ML - Federal Reserve Economic Data Machine Learning System" in content:
            print("βœ… README has been updated")
        else:
            print("❌ README updates not found")
            return False
    
    return True

def main():
    """Run simple tests"""
    print("πŸš€ Starting Simple Local Tests...")
    print("=" * 40)
    
    tests = [
        test_app_running,
        test_fred_api_key,
        test_file_updates
    ]
    
    passed = 0
    total = len(tests)
    
    for test in tests:
        try:
            if test():
                passed += 1
        except Exception as e:
            print(f"❌ Test {test.__name__} failed: {e}")
        print()
    
    print("=" * 40)
    print(f"πŸ“Š Results: {passed}/{total} tests passed")
    
    if passed == total:
        print("πŸŽ‰ All tests passed!")
        print("\nβœ… Local app is working correctly")
        print("🌐 Open http://localhost:8501 in your browser")
        print("\nπŸ“‹ What to check manually:")
        print("  - Look for 'FRED ML v2.0.1' banner at the top")
        print("  - Check that all pages load without errors")
        print("  - Verify economic data is displayed")
        print("  - Test downloads section functionality")
    else:
        print("⚠️ Some tests failed. Check the output above.")
    
    print(f"\n🌐 Local App URL: http://localhost:8501")

if __name__ == "__main__":
    main()