-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api.py
More file actions
50 lines (40 loc) · 1.5 KB
/
test_api.py
File metadata and controls
50 lines (40 loc) · 1.5 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
"""Test script to verify the classification API."""
import requests
import json
BASE_URL = "http://localhost:8080"
def test_health():
"""Test health endpoint."""
print("🔍 Testing health endpoint...")
response = requests.get(f"{BASE_URL}/health")
print(f"Status: {response.status_code}")
print(f"Response: {json.dumps(response.json(), indent=2)}\n")
def test_classify():
"""Test classification endpoint."""
print("🔍 Testing classification endpoint...")
test_title = "Mejoramiento del servicio de agua potable en el distrito de San Juan"
response = requests.post(
f"{BASE_URL}/api/v1/classify",
json={"title": test_title}
)
print(f"Status: {response.status_code}")
print(f"Request: {test_title}")
print(f"Response:\n{json.dumps(response.json(), indent=2, ensure_ascii=False)}\n")
def test_categories():
"""Test categories endpoint."""
print("🔍 Testing categories endpoint...")
response = requests.get(f"{BASE_URL}/api/v1/categories")
print(f"Status: {response.status_code}")
data = response.json()
print(f"Total categories: {data.get('total')}")
print(f"Categories: {list(data.get('categories', {}).keys())}\n")
if __name__ == "__main__":
print("=" * 60)
print("Brecha AI Service - API Test")
print("=" * 60 + "\n")
try:
test_health()
test_categories()
test_classify()
print("✅ All tests completed!")
except Exception as e:
print(f"❌ Error: {e}")