voiceCal-ai-v3 / unit_tests /run_all_tests.py
pgits's picture
TESTS: Organize tests into unit_tests directory with runner
1e041ce
#!/usr/bin/env python3
"""
Run all VoiceCal.ai unit tests.
Usage:
python3 run_all_tests.py
# On HuggingFace SSH:
ssh -i ~/.ssh/id_ed25519 pgits-voicecal-ai@ssh.hf.space
cd /app/unit_tests && python run_all_tests.py
"""
import sys
import os
import importlib.util
from pathlib import Path
# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent.parent))
def run_test_module(test_file):
"""Run a single test module."""
module_name = test_file.stem
print(f"\n{'=' * 70}")
print(f"Running: {module_name}")
print('=' * 70)
try:
# Load the module
spec = importlib.util.spec_from_file_location(module_name, test_file)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
# Look for main function or just run the module
if hasattr(module, 'main'):
result = module.main()
return (module_name, result)
else:
print(f"βœ… {module_name} executed successfully")
return (module_name, True)
except Exception as e:
print(f"❌ {module_name} failed: {e}")
import traceback
traceback.print_exc()
return (module_name, False)
def main():
"""Run all tests in the unit_tests directory."""
print("=" * 70)
print("VOICECAL.AI - UNIT TEST RUNNER")
print("=" * 70)
# Find all test files
tests_dir = Path(__file__).parent
test_files = sorted(tests_dir.glob("test_*.py"))
if not test_files:
print("❌ No test files found!")
return False
print(f"\nFound {len(test_files)} test(s):")
for test_file in test_files:
print(f" - {test_file.name}")
# Run each test
results = []
for test_file in test_files:
result = run_test_module(test_file)
results.append(result)
# Summary
print("\n" + "=" * 70)
print("TEST SUMMARY")
print("=" * 70)
passed = sum(1 for _, result in results if result)
failed = len(results) - passed
for test_name, result in results:
status = "βœ… PASS" if result else "❌ FAIL"
print(f"{status}: {test_name}")
print("\n" + "=" * 70)
print(f"Results: {passed} passed, {failed} failed out of {len(results)} total")
print("=" * 70)
return failed == 0
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)