#!/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())