-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_api_tests.py
More file actions
115 lines (91 loc) · 2.97 KB
/
run_api_tests.py
File metadata and controls
115 lines (91 loc) · 2.97 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env python3
"""
Test runner script to demonstrate API test structure and functionality
"""
import sys
import os
import pytest
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root))
def run_api_tests():
"""Run API tests with verbose output"""
print("=" * 70)
print("INTEGRAL PHILOSOPHY PUBLISHING SYSTEM - API TEST SUITE")
print("=" * 70)
# Change to tests directory
tests_dir = Path(__file__).parent / "tests"
os.chdir(tests_dir)
# Run pytest with specific markers and options
args = [
"api/",
"-v",
"--tb=short",
"--durations=10",
"-x", # Stop on first failure
"--disable-warnings",
]
print(f"Running: pytest {' '.join(args)}")
print()
# Run the tests
result = pytest.main(args)
print("\n" + "=" * 70)
print("API TEST SUMMARY")
print("=" * 70)
if result == 0:
print("✅ All API tests passed!")
elif result == 1:
print("❌ Some API tests failed")
elif result == 2:
print("⚠️ Test execution interrupted")
else:
print(f"❓ Unknown result code: {result}")
print(f"\n📊 Test Result Code: {result}")
print("\n📋 Test Categories Covered:")
print(" 🧪 Authentication Tests")
print(" 🔄 Job Management Tests")
print(" 🔌 API Endpoint Tests")
print(" 📁 File Operations Tests")
print("\n🔍 Test Features:")
print(" • Comprehensive API coverage")
print(" • Security testing")
print(" • Error handling validation")
print(" • Performance testing")
print(" • Concurrent operation testing")
return result
def validate_test_structure():
"""Validate that all test files are properly structured"""
print("\n" + "=" * 70)
print("VALIDATING TEST STRUCTURE")
print("=" * 70)
api_tests_dir = Path(__file__).parent / "tests" / "api"
test_files = [
"test_authentication.py",
"test_job_management.py",
"test_endpoints.py",
"test_file_operations.py",
]
for test_file in test_files:
file_path = api_tests_dir / test_file
if file_path.exists():
print(f"✅ {test_file} exists")
# Check for basic structure
content = file_path.read_text()
if "class Test" in content:
print(f" ✅ Contains test classes")
if "def test_" in content:
print(f" ✅ Contains test methods")
if "APITestCase" in content:
print(f" ✅ Inherits from APITestCase")
else:
print(f"❌ {test_file} missing")
print("\n📊 Test Structure Validation Complete")
if __name__ == "__main__":
print("🚀 Starting API Test Runner")
# Validate structure first
validate_test_structure()
# Run the tests
result = run_api_tests()
# Exit with appropriate code
sys.exit(result)