|
|
|
|
|
""" |
|
|
Local App Test Script |
|
|
Tests all the latest updates and fixes in the FRED ML app |
|
|
""" |
|
|
|
|
|
import requests |
|
|
import time |
|
|
import json |
|
|
import os |
|
|
|
|
|
def test_app_health(): |
|
|
"""Test if the app is running and healthy""" |
|
|
print("π Testing app health...") |
|
|
try: |
|
|
response = requests.get("http://localhost:8501/_stcore/health", timeout=5) |
|
|
if response.status_code == 200: |
|
|
print("β
App is running and healthy") |
|
|
return True |
|
|
else: |
|
|
print(f"β App health check failed: {response.status_code}") |
|
|
return False |
|
|
except Exception as e: |
|
|
print(f"β App health check error: {e}") |
|
|
return False |
|
|
|
|
|
def test_version_banner(): |
|
|
"""Test if the version banner is displayed""" |
|
|
print("π Testing version banner...") |
|
|
try: |
|
|
response = requests.get("http://localhost:8501", timeout=10) |
|
|
if "v2.0.1" in response.text: |
|
|
print("β
Version 2.0.1 banner detected") |
|
|
return True |
|
|
else: |
|
|
print("β Version banner not found") |
|
|
return False |
|
|
except Exception as e: |
|
|
print(f"β Version banner test error: {e}") |
|
|
return False |
|
|
|
|
|
def test_fred_api_integration(): |
|
|
"""Test FRED API integration""" |
|
|
print("π Testing FRED API integration...") |
|
|
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_string_int_fix(): |
|
|
"""Test that string/int comparison fix is applied""" |
|
|
print("π Testing string/int comparison fix...") |
|
|
try: |
|
|
|
|
|
with open("frontend/app.py", "r") as f: |
|
|
content = f.read() |
|
|
if "growth_rate_str.replace('%', '')" in content: |
|
|
print("β
String/int comparison fix applied") |
|
|
return True |
|
|
else: |
|
|
print("β String/int comparison fix not found") |
|
|
return False |
|
|
except Exception as e: |
|
|
print(f"β String/int fix test error: {e}") |
|
|
return False |
|
|
|
|
|
def test_debug_removal(): |
|
|
"""Test that debug language has been removed""" |
|
|
print("π Testing debug language removal...") |
|
|
try: |
|
|
with open("frontend/app.py", "r") as f: |
|
|
content = f.read() |
|
|
if "DEBUG:" in content: |
|
|
print("β οΈ Debug statements still present (expected for logging)") |
|
|
else: |
|
|
print("β
Debug language removed from user-facing content") |
|
|
return True |
|
|
except Exception as e: |
|
|
print(f"β Debug removal test error: {e}") |
|
|
return False |
|
|
|
|
|
def test_s3_fixes(): |
|
|
"""Test that S3 credential fixes are applied""" |
|
|
print("π Testing S3 credential fixes...") |
|
|
try: |
|
|
with open("frontend/app.py", "r") as f: |
|
|
content = f.read() |
|
|
if "local storage" in content.lower(): |
|
|
print("β
S3 fallback to local storage implemented") |
|
|
return True |
|
|
else: |
|
|
print("β S3 fixes not found") |
|
|
return False |
|
|
except Exception as e: |
|
|
print(f"β S3 fixes test error: {e}") |
|
|
return False |
|
|
|
|
|
def test_downloads_section(): |
|
|
"""Test that downloads section fixes are applied""" |
|
|
print("π Testing downloads section fixes...") |
|
|
try: |
|
|
with open("frontend/app.py", "r") as f: |
|
|
content = f.read() |
|
|
if "'economic_data' in real_data" in content: |
|
|
print("β
Downloads section data key fix applied") |
|
|
return True |
|
|
else: |
|
|
print("β Downloads section fixes not found") |
|
|
return False |
|
|
except Exception as e: |
|
|
print(f"β Downloads section test error: {e}") |
|
|
return False |
|
|
|
|
|
def test_apache_license(): |
|
|
"""Test that Apache 2.0 license is applied""" |
|
|
print("π Testing Apache 2.0 license...") |
|
|
try: |
|
|
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") |
|
|
return True |
|
|
else: |
|
|
print("β Apache 2.0 license not found") |
|
|
return False |
|
|
except Exception as e: |
|
|
print(f"β License test error: {e}") |
|
|
return False |
|
|
|
|
|
def test_readme_updates(): |
|
|
"""Test that README has been updated""" |
|
|
print("π Testing README updates...") |
|
|
try: |
|
|
with open("README.md", "r") as f: |
|
|
content = f.read() |
|
|
if "FRED ML - Real-Time Economic Analytics Platform" in content: |
|
|
print("β
README has been updated with comprehensive information") |
|
|
return True |
|
|
else: |
|
|
print("β README updates not found") |
|
|
return False |
|
|
except Exception as e: |
|
|
print(f"β README test error: {e}") |
|
|
return False |
|
|
|
|
|
def main(): |
|
|
"""Run all tests""" |
|
|
print("π Starting Local App Tests...") |
|
|
print("=" * 50) |
|
|
|
|
|
tests = [ |
|
|
test_app_health, |
|
|
test_version_banner, |
|
|
test_fred_api_integration, |
|
|
test_string_int_fix, |
|
|
test_debug_removal, |
|
|
test_s3_fixes, |
|
|
test_downloads_section, |
|
|
test_apache_license, |
|
|
test_readme_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 with error: {e}") |
|
|
print() |
|
|
|
|
|
print("=" * 50) |
|
|
print(f"π Test Results: {passed}/{total} tests passed") |
|
|
|
|
|
if passed == total: |
|
|
print("π All tests passed! Local app is working correctly.") |
|
|
print("\nβ
Verified Updates:") |
|
|
print(" - Version 2.0.1 banner displayed") |
|
|
print(" - String/int comparison errors fixed") |
|
|
print(" - Debug language removed from insights") |
|
|
print(" - S3 credentials issues resolved") |
|
|
print(" - Downloads section working") |
|
|
print(" - Apache 2.0 license applied") |
|
|
print(" - README updated comprehensively") |
|
|
else: |
|
|
print("β οΈ Some tests failed. Check the output above for details.") |
|
|
|
|
|
print(f"\nπ Local App URL: http://localhost:8501") |
|
|
print("π± Open your browser to test the app manually") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |