File size: 2,000 Bytes
bcc2f7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/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())