95 lines
No EOL
2.4 KiB
Python
95 lines
No EOL
2.4 KiB
Python
"""Run all tests in the test suite."""
|
|
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
# Add parent directory to path
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
|
|
def run_test(test_file: str) -> bool:
|
|
"""Run a single test file and return success status."""
|
|
print(f"\n{'='*60}")
|
|
print(f"Running {test_file}...")
|
|
print('='*60)
|
|
|
|
try:
|
|
result = subprocess.run(
|
|
[sys.executable, test_file],
|
|
capture_output=True,
|
|
text=True,
|
|
check=True
|
|
)
|
|
print(result.stdout)
|
|
if result.stderr:
|
|
print("Warnings:", result.stderr)
|
|
return True
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"❌ Test failed: {test_file}")
|
|
print("STDOUT:", e.stdout)
|
|
print("STDERR:", e.stderr)
|
|
return False
|
|
|
|
|
|
def main():
|
|
"""Run all tests."""
|
|
print("🚀 AI Router Test Suite")
|
|
print("=" * 60)
|
|
|
|
# Load environment variables
|
|
from dotenv import load_dotenv
|
|
env_path = Path(__file__).parent.parent / ".env"
|
|
if env_path.exists():
|
|
load_dotenv(env_path)
|
|
print(f"✓ Loaded environment from {env_path}")
|
|
else:
|
|
print("⚠ No .env file found, using system environment")
|
|
|
|
# Test files in order
|
|
test_files = [
|
|
"test_config.py",
|
|
"test_embeddings.py",
|
|
"test_rerank.py",
|
|
"test_generation.py",
|
|
]
|
|
|
|
# Track results
|
|
results = {}
|
|
tests_dir = Path(__file__).parent
|
|
|
|
for test_file in test_files:
|
|
test_path = tests_dir / test_file
|
|
if test_path.exists():
|
|
results[test_file] = run_test(str(test_path))
|
|
else:
|
|
print(f"⚠ Test file not found: {test_file}")
|
|
results[test_file] = False
|
|
|
|
# Summary
|
|
print("\n" + "="*60)
|
|
print("📊 TEST SUMMARY")
|
|
print("="*60)
|
|
|
|
passed = sum(1 for success in results.values() if success)
|
|
total = len(results)
|
|
|
|
for test_file, success in results.items():
|
|
status = "✅ PASSED" if success else "❌ FAILED"
|
|
print(f"{test_file:<30} {status}")
|
|
|
|
print("-"*60)
|
|
print(f"Total: {passed}/{total} tests passed")
|
|
|
|
if passed == total:
|
|
print("\n🎉 All tests passed!")
|
|
return 0
|
|
else:
|
|
print(f"\n❌ {total - passed} test(s) failed")
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
exit_code = main()
|
|
sys.exit(exit_code) |