-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·131 lines (105 loc) · 4.02 KB
/
run_tests.py
File metadata and controls
executable file
·131 lines (105 loc) · 4.02 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
#!/usr/bin/env python3
"""
Simple test runner for parse_borealis_data.py
This script runs all tests and provides a summary of results.
Uses only built-in Python modules.
"""
import subprocess
import sys
import os
import test_fixtures
def run_tests():
"""Run the test suite and return success status."""
print("Running Borealis Data Parser Tests...")
print("=" * 50)
try:
# Run the tests using unittest module
result = subprocess.run(
[sys.executable, "-m", "unittest", "test_parse_borealis_data.py", "-v"],
capture_output=True,
text=True,
cwd=os.path.dirname(__file__),
)
print(result.stdout)
if result.stderr:
print("STDERR:")
print(result.stderr)
if result.returncode == 0:
print("\n" + "=" * 50)
print("✅ ALL TESTS PASSED!")
print("=" * 50)
return True
else:
print("\n" + "=" * 50)
print("❌ SOME TESTS FAILED!")
print("=" * 50)
return False
except Exception as e:
print(f"Error running tests: {e}")
return False
def run_example_tests():
"""Run tests with all fixture data."""
print("\nRunning fixture data validation...")
print("-" * 30)
fixtures = test_fixtures.get_all_fixtures()
total_tests = 0
success_count = 0
for data_type, fixture_list in fixtures.items():
print(f"\nTesting {data_type.upper()} data ({len(fixture_list)} fixtures)...")
for fixture in fixture_list:
total_tests += 1
try:
# Prepare command arguments
cmd = [
sys.executable,
"parse_borealis_data.py",
"--data-type",
data_type,
]
# Add df parameter for pgram data
if data_type == "pgram" and "df" in fixture:
cmd.extend(["--df", str(fixture["df"])])
result = subprocess.run(
cmd,
input=fixture["base64"],
capture_output=True,
text=True,
cwd=os.path.dirname(__file__),
)
if result.returncode == 0 and result.stdout:
lines = result.stdout.strip().split("\n")
# Filter out comment lines (starting with #)
data_lines = [line for line in lines if not line.startswith("#")]
if len(data_lines) > 1: # Header + at least one data line
print(
f" ✅ {fixture['name']}: {len(data_lines)-1} data points"
)
success_count += 1
else:
print(f" ❌ {fixture['name']}: No data returned")
else:
print(f" ❌ {fixture['name']}: Parsing failed")
if result.stderr:
print(f" Error: {result.stderr.strip()}")
except Exception as e:
print(f" ❌ {fixture['name']}: Test failed with exception: {e}")
print(f"\nFixture validation: {success_count}/{total_tests} passed")
return success_count == total_tests
if __name__ == "__main__":
print("Borealis Data Parser Test Suite")
print("================================")
# Run unit tests
unit_tests_passed = run_tests()
# Run example validation tests
example_tests_passed = run_example_tests()
# Final summary
print("\n" + "=" * 50)
print("FINAL SUMMARY:")
print(f"Unit Tests: {'PASSED' if unit_tests_passed else 'FAILED'}")
print(f"Example Tests: {'PASSED' if example_tests_passed else 'FAILED'}")
if unit_tests_passed and example_tests_passed:
print("\n🎉 ALL TESTS PASSED! The parser is working correctly.")
sys.exit(0)
else:
print("\n💥 SOME TESTS FAILED! Please check the output above.")
sys.exit(1)