-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
60 lines (47 loc) · 2.57 KB
/
run_tests.py
File metadata and controls
60 lines (47 loc) · 2.57 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
import sys
sys.path.insert(0, '.')
print('=== TESTING ALL COMPONENTS ===')
print()
# Test 1: Import all modules
print('[1] Testing imports...')
from web.app import app, load_models
print(' web.app: OK')
# Test 2: Load models
print('[2] Loading models...')
result = load_models()
print(f' Models loaded: {result}')
# Test 3: Test all endpoints
print('[3] Testing API endpoints...')
with app.test_client() as client:
# Sorting
r = client.post('/api/recommend/sorting', json={'array': '5, 2, 8, 1, 9'})
print(f' Sorting: {r.status_code} - {r.get_json().get("algorithm", "ERROR")}')
# Array search
r = client.post('/api/recommend/array-search', json={'array': '1, 2, 3, 4, 5', 'target': 3})
print(f' Array Search: {r.status_code} - {r.get_json().get("algorithm", "ERROR")}')
# Graph search
r = client.post('/api/recommend/graph-search', json={'num_nodes': 10, 'is_weighted': True, 'has_negative': False, 'density': 0.3})
print(f' Graph Search: {r.status_code} - {r.get_json().get("algorithm", "ERROR")}')
# String search
r = client.post('/api/recommend/string-search', json={'text': 'hello world', 'patterns': ['world', 'hello']})
data = r.get_json()
print(f' String Search: {r.status_code} - {data.get("algorithm", "ERROR")}')
print(f' - detailed_reasoning: {len(data.get("detailed_reasoning", []))} items')
print(f' - constraint_analysis: {"YES" if data.get("constraint_analysis") else "MISSING"}')
print(f' - string_stats: {"YES" if data.get("string_stats") else "MISSING"}')
# Tree search
r = client.post('/api/recommend/tree-search', json={'keys': [50, 30, 70, 20, 40, 60, 80], 'tree_type': 'bst'})
data = r.get_json()
print(f' Tree Search: {r.status_code} - {data.get("algorithm", "ERROR")}')
print(f' - detailed_reasoning: {len(data.get("detailed_reasoning", []))} items')
print(f' - constraint_analysis: {"YES" if data.get("constraint_analysis") else "MISSING"}')
print(f' - tree_stats: {"YES" if data.get("tree_stats") else "MISSING"}')
# Execute endpoints
r = client.post('/api/execute/sorting', json={'array': '5, 2, 8, 1, 9'})
print(f' Execute Sorting: {r.status_code}')
r = client.post('/api/execute/string-search', json={'text': 'hello world', 'patterns': ['world']})
print(f' Execute String: {r.status_code}')
r = client.post('/api/execute/tree-search', json={'keys': [50, 30, 70], 'tree_type': 'bst', 'search_key': 30})
print(f' Execute Tree: {r.status_code}')
print()
print('=== ALL TESTS PASSED ===')