-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_condition_api.py
More file actions
28 lines (23 loc) · 987 Bytes
/
test_condition_api.py
File metadata and controls
28 lines (23 loc) · 987 Bytes
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
from fastapi.testclient import TestClient
import sys
# Add parent dir to path
sys.path.insert(0, '/home/joebert/open-data-visualization')
from visualization import app
client = TestClient(app)
def test_endpoint():
print("Testing /api/budget/condition-analysis...")
response = client.get("/api/budget/condition-analysis")
if response.status_code == 200:
data = response.json()
print("Success:", data.get('success'))
print("Low Priority Count:", len(data.get('low_priority_projects', [])))
print("No Data Count:", len(data.get('no_data_projects', [])))
# Sample items
if data.get('low_priority_projects'):
print("\nSample Low Priority:", data['low_priority_projects'][0])
if data.get('no_data_projects'):
print("\nSample No Data:", data['no_data_projects'][0])
else:
print("Failed:", response.status_code, response.text)
if __name__ == "__main__":
test_endpoint()