fishapi / run_tests.py
kamau1's picture
Initial commit
bcc2f7b verified
#!/usr/bin/env python3
"""
Test runner script for the Marine Species Identification API.
"""
import subprocess
import sys
import os
from pathlib import Path
def run_pytest():
"""Run pytest tests."""
print("πŸ§ͺ Running pytest tests...")
try:
result = subprocess.run([
sys.executable, "-m", "pytest",
"tests/",
"-v",
"--tb=short"
], check=True)
print("βœ… All pytest tests passed!")
return True
except subprocess.CalledProcessError as e:
print(f"❌ Some pytest tests failed (exit code: {e.returncode})")
return False
except FileNotFoundError:
print("⚠️ pytest not found, skipping pytest tests")
return True
def run_simple_test():
"""Run the simple API test."""
print("πŸ§ͺ Running simple API test...")
try:
result = subprocess.run([
sys.executable, "test_api_simple.py"
], check=True)
print("βœ… Simple API test completed!")
return True
except subprocess.CalledProcessError as e:
print(f"❌ Simple API test failed (exit code: {e.returncode})")
return False
def main():
"""Main test runner."""
print("🐟 Marine Species Identification API - Test Runner")
print("=" * 55)
# Change to project directory
project_dir = Path(__file__).parent
os.chdir(project_dir)
success = True
# Run pytest tests
if not run_pytest():
success = False
print()
# Note about simple test
print("πŸ“ Note: To run the simple API test, start the API first:")
print(" python start_api.py")
print(" # Then in another terminal:")
print(" python test_api_simple.py")
print("=" * 55)
if success:
print("πŸŽ‰ All available tests completed successfully!")
return 0
else:
print("❌ Some tests failed")
return 1
if __name__ == "__main__":
sys.exit(main())