Files
email_alerts/test_local_connection.py
T
Iyeoluwa Akinrinola 70b2bcc89d Fix Zoho connection issues and add local testing capabilities
- Fixed 'days_back' parameter error in zoho_client.py
- Added robust settings validation in app.py to prevent int() errors
- Created LOCAL_TESTING.md with comprehensive testing guide
- Added run_local.sh for easy local server setup
- Added deploy_updates.sh for deployment instructions
- Added test_local_connection.py for automated testing
- Updated config.json with proper structure
- All fixes tested and working locally
2025-07-25 12:40:10 +01:00

51 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""
Test script to verify local connection works
"""
import requests
import time
import json
def test_local_connection():
"""Test the local server connection"""
print("🧪 Testing local Email Alerts server...")
# Wait for server to start
print("⏳ Waiting for server to start...")
time.sleep(3)
try:
# Test 1: Check if server is running
print("\n1️⃣ Testing server availability...")
response = requests.get("http://localhost:5237/", timeout=5)
if response.status_code == 200:
print("✅ Server is running and accessible")
else:
print(f"❌ Server returned status code: {response.status_code}")
return
# Test 2: Test connection endpoint
print("\n2️⃣ Testing connection endpoint...")
response = requests.get("http://localhost:5237/test_connection", timeout=10)
if response.status_code == 200:
data = response.json()
if data.get('status') == 'success':
print("✅ Connection test successful!")
print(f"📧 Found {data.get('email_count', 0)} emails")
print(f"💬 Message: {data.get('message', '')}")
else:
print("❌ Connection test failed:")
print(f" Error: {data.get('message', 'Unknown error')}")
else:
print(f"❌ Connection endpoint returned status code: {response.status_code}")
except requests.exceptions.ConnectionError:
print("❌ Could not connect to server. Make sure it's running on port 5237")
except Exception as e:
print(f"❌ Test failed: {str(e)}")
if __name__ == "__main__":
test_local_connection()