-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_setup.py
More file actions
146 lines (119 loc) · 4.34 KB
/
Copy pathtest_setup.py
File metadata and controls
146 lines (119 loc) · 4.34 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env python3
"""
Quick test script to verify the GitHub Productivity Analytics setup.
Run this after setting up config.py to ensure everything works.
"""
import sys
from pathlib import Path
def test_imports():
"""Test that all required modules can be imported."""
print("🧪 Testing imports...")
try:
import pandas
print("✅ pandas imported successfully")
except ImportError as e:
print(f"❌ pandas import failed: {e}")
return False
try:
import requests
print("✅ requests imported successfully")
except ImportError as e:
print(f"❌ requests import failed: {e}")
return False
try:
import plotly
print("✅ plotly imported successfully")
except ImportError as e:
print(f"❌ plotly import failed: {e}")
return False
return True
def test_config():
"""Test that config.py is properly set up."""
print("\n⚙️ Testing configuration...")
if not Path("config.py").exists():
print("❌ config.py not found. Run: cp config.example.py config.py")
return False
try:
import config
print("✅ config.py imported successfully")
# Check required settings
required_attrs = ['GITHUB_TOKEN', 'ORG_NAME', 'CORE_TEAM']
for attr in required_attrs:
if hasattr(config, attr):
value = getattr(config, attr)
if value:
print(f"✅ {attr} is set")
else:
print(f"⚠️ {attr} is empty - please set it in config.py")
else:
print(f"❌ {attr} not found in config.py")
return False
return True
except Exception as e:
print(f"❌ config.py error: {e}")
return False
def test_github_connection():
"""Test GitHub API connectivity."""
print("\n🌐 Testing GitHub connection...")
try:
import config
import requests
if not config.GITHUB_TOKEN:
print("⚠️ No GitHub token set - skipping connection test")
return True
headers = {
'Authorization': f'token {config.GITHUB_TOKEN}',
'Accept': 'application/vnd.github.v3+json'
}
# Test basic API access
response = requests.get('https://api.github.com/user', headers=headers, timeout=10)
if response.status_code == 200:
user_data = response.json()
print(f"✅ GitHub API connection successful")
print(f" Authenticated as: {user_data.get('login', 'Unknown')}")
return True
else:
print(f"❌ GitHub API error: {response.status_code}")
print(f" Response: {response.text[:100]}...")
return False
except Exception as e:
print(f"❌ GitHub connection test failed: {e}")
return False
def main():
"""Run all tests."""
print("🚀 GitHub Productivity Analytics - System Test")
print("=" * 60)
tests = [
("Import Test", test_imports),
("Configuration Test", test_config),
("GitHub Connection Test", test_github_connection),
]
results = []
for test_name, test_func in tests:
try:
result = test_func()
results.append((test_name, result))
except Exception as e:
print(f"❌ {test_name} crashed: {e}")
results.append((test_name, False))
print("\n" + "=" * 60)
print("📋 Test Summary:")
all_passed = True
for test_name, passed in results:
status = "✅ PASS" if passed else "❌ FAIL"
print(f" {status} {test_name}")
if not passed:
all_passed = False
if all_passed:
print("\n🎉 All tests passed! You're ready to run the analysis.")
print("\nNext steps:")
print(" 1. python extract.py")
print(" 2. python web_dashboard.py")
print(" 3. Open productivity_dashboard.html in your browser")
else:
print("\n🔧 Please fix the failing tests before proceeding.")
print(" Check the error messages above for guidance.")
return 1
return 0
if __name__ == "__main__":
sys.exit(main())