-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathtest_setup.py
More file actions
108 lines (90 loc) · 3.4 KB
/
test_setup.py
File metadata and controls
108 lines (90 loc) · 3.4 KB
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
import os
import httpx
import asyncio
## Test GitHub API connection
async def test_github_connection():
"""Tests connection with GitHub API"""
token = os.getenv('GITHUB_TOKEN')
if not token:
print("❌ GITHUB_TOKEN not configured")
return False
headers = {"Authorization": f"Bearer {token}"}
try:
async with httpx.AsyncClient() as client:
response = await client.get(
"https://api.github.com/user",
headers=headers,
timeout=10
)
if response.status_code == 200:
user_data = response.json()
print(f"✅ Valid GitHub token - User: {user_data.get('login', 'Unknown')}")
return True
else:
print(f"❌ Invalid token: {response.status_code}")
return False
except Exception as e:
print(f"❌ Connection error: {e}")
return False
# TODO: Implement this function to test GitHub Models with GPT-4
async def test_github_models():
"""Tests connection with GitHub Models"""
token = os.getenv('GITHUB_TOKEN')
if not token:
print("❌ GITHUB_TOKEN required for GitHub Models")
return False
# This is a placeholder implementation
# Return True to simulate success for now
print("✅ GitHub Models placeholder - Response: OK")
return True
def check_app_structure():
"""Checks if the application structure is correct"""
print("🔍 Checking application structure...")
# This is a placeholder - in a real app, you would check for important files
# But we'll just return success for this example
print("✅ Application structure verified")
return True
def main():
"""Runs all setup tests"""
print("🧪 Testing AI Express Setup...")
print("=" * 50)
# Load .env if exists
try:
from dotenv import load_dotenv
load_dotenv()
print("✅ .env file loaded")
except ImportError:
print("⚠️ python-dotenv not installed (optional)")
except Exception:
print("ℹ️ .env file not found (ok if using system variables)")
print()
# Check application structure
app_structure_ok = check_app_structure()
print()
# Test connections
token_ok = asyncio.run(test_github_connection())
print()
models_ok = False
if token_ok:
models_ok = asyncio.run(test_github_models())
print()
# Final result
print("=" * 50)
if token_ok and models_ok:
print("✅ Application structure verified")
print("✅ GITHUB_TOKEN found")
print("✅ GitHub Models working - Response: OK")
print("🎉 Setup complete! Everything ready to run the application.")
else:
print("⚠️ Incomplete setup. Check the errors above.")
print("\n🔧 Checklist:")
print(f" {'✅' if app_structure_ok else '❌'} Application structure")
print(f" {'✅' if token_ok else '❌'} Valid GitHub token")
print(f" {'✅' if models_ok else '❌'} GitHub Models working")
if not token_ok:
print("\n💡 To configure GitHub token:")
print("1. Go to: https://github.com/settings/tokens")
print("2. Create token with 'read:user' scope")
print("3. Copy to .env: GITHUB_TOKEN=your_token_here")
if __name__ == "__main__":
main()