triage-flow / tests /test_endpoints.py
StrongCapybara's picture
feat: complete TriageFlow environment for Hackathon Submission
0cb452d
Raw
History Blame Contribute Delete
1.03 kB
"""Test HTTP endpoints against running server."""
import httpx
BASE = "http://127.0.0.1:8000"
# Health
r = httpx.get(f"{BASE}/health")
print(f"Health: {r.status_code} {r.text}")
# Reset with empty body (required for pre-submission validator)
r = httpx.post(f"{BASE}/reset", json={})
print(f"Reset (empty): {r.status_code}")
# Reset with task_name
r = httpx.post(f"{BASE}/reset", json={"task_name": "basic-triage"})
data = r.json()
obs = data.get("observation", data)
pid = obs.get("current_patient", {}).get("patient_id", "?")
print(f"Reset (basic-triage): {r.status_code}, patient={pid}")
# Step
r = httpx.post(f"{BASE}/step", json={
"action_type": "assign_priority",
"patient_id": "P001",
"priority_level": "immediate"
})
data = r.json()
print(f"Step: {r.status_code}, reward={data.get('reward', '?')}, done={data.get('done', '?')}")
# State
r = httpx.get(f"{BASE}/state")
state = r.json()
print(f"State: {r.status_code}, assignments={state.get('assignments', {})}")
print("\nALL ENDPOINT TESTS PASSED!")