-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
184 lines (146 loc) · 5.9 KB
/
run_tests.py
File metadata and controls
184 lines (146 loc) · 5.9 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/env python3
"""
ISS Speed Analysis Dashboard - Easy Test Runner
Just run this file like any other Python script:
python run_tests.py
This will run all tests and show you a nice summary.
"""
import sys
import os
import unittest
import subprocess
from pathlib import Path
def main():
"""Run all tests with a simple interface"""
print("🚀 ISS Speed Analysis Dashboard - Test Suite")
print("=" * 60)
print("Running comprehensive tests to verify data integrity...")
print()
# Check if we're in the right directory
if not os.path.exists('iss_speed_html_dashboard_v2_clean.py'):
print("❌ Error: iss_speed_html_dashboard_v2_clean.py not found!")
print(" Make sure you're in the correct directory.")
return False
# Check if tests directory exists
if not os.path.exists('tests'):
print("❌ Error: tests directory not found!")
print(" The test suite hasn't been set up yet.")
return False
try:
# Run the tests using unittest
loader = unittest.TestLoader()
start_dir = 'tests'
suite = loader.discover(start_dir, pattern='test_*.py')
# Run the tests
runner = unittest.TextTestRunner(verbosity=2)
result = runner.run(suite)
# Print summary
print("\n" + "=" * 60)
print("📊 TEST SUMMARY")
print("=" * 60)
total_tests = result.testsRun
failures = len(result.failures)
errors = len(result.errors)
passed = total_tests - failures - errors
print(f"Total Tests: {total_tests}")
print(f"✅ Passed: {passed}")
print(f"❌ Failed: {failures}")
print(f"💥 Errors: {errors}")
if total_tests > 0:
success_rate = (passed / total_tests) * 100
print(f"Success Rate: {success_rate:.1f}%")
# Show results
if failures == 0 and errors == 0:
print("\n🎉 ALL TESTS PASSED!")
print("✅ Data integrity verified from backend to frontend")
print("✅ Your ISS Speed Analysis Dashboard is working correctly!")
return True
else:
print(f"\n⚠️ {failures + errors} test(s) failed")
print("Please review the output above for details.")
if failures > 0:
print("\n❌ FAILURES:")
for test, traceback in result.failures:
print(f" - {test}")
if errors > 0:
print("\n💥 ERRORS:")
for test, traceback in result.errors:
print(f" - {test}")
return False
except Exception as e:
print(f"❌ Error running tests: {e}")
print("\nTroubleshooting:")
print("1. Make sure you're in the correct directory")
print("2. Check that all test files exist")
print("3. Try running: pip install -r requirements-test.txt")
return False
def run_quick_test():
"""Run a quick test to verify the system is working"""
print("🔍 Running quick system check...")
try:
# Try to import the main module
import iss_speed_html_dashboard_v2_clean
print("✅ Main module imports successfully")
# Check if Flask app can be created
app = iss_speed_html_dashboard_v2_clean.app
print("✅ Flask app created successfully")
# Check if test directory exists
if os.path.exists('tests'):
print("✅ Test directory found")
else:
print("❌ Test directory not found")
return False
print("✅ System check passed!")
return True
except Exception as e:
print(f"❌ System check failed: {e}")
return False
if __name__ == "__main__":
print("ISS Speed Analysis Dashboard - Test Runner")
print("=" * 50)
# First, run a quick system check
if not run_quick_test():
print("\n❌ System check failed. Please fix the issues above.")
sys.exit(1)
print()
# Ask user what they want to do
print("What would you like to do?")
print("1. Run all tests (recommended)")
print("2. Run quick tests only")
print("3. Exit")
try:
choice = input("\nEnter your choice (1-3): ").strip()
if choice == "1":
print("\n🚀 Running full test suite...")
success = main()
sys.exit(0 if success else 1)
elif choice == "2":
print("\n🔍 Running quick tests...")
# Run just a few key tests
loader = unittest.TestLoader()
suite = unittest.TestSuite()
# Add a few key tests
try:
from tests.unit.test_backend_functions import TestBackendFunctions
suite.addTest(TestBackendFunctions('test_calculate_statistics'))
suite.addTest(TestBackendFunctions('test_data_integrity_through_pipeline'))
runner = unittest.TextTestRunner(verbosity=2)
result = runner.run(suite)
if result.wasSuccessful():
print("✅ Quick tests passed!")
else:
print("❌ Quick tests failed!")
except Exception as e:
print(f"❌ Error running quick tests: {e}")
elif choice == "3":
print("👋 Goodbye!")
sys.exit(0)
else:
print("❌ Invalid choice. Please run the script again.")
sys.exit(1)
except KeyboardInterrupt:
print("\n\n👋 Test run cancelled by user.")
sys.exit(0)
except Exception as e:
print(f"\n❌ Unexpected error: {e}")
sys.exit(1)