from fastapi.testclient import TestClient from app.main import app client = TestClient(app) def test_health_endpoint(): response = client.get("/health") assert response.status_code == 200 assert response.json() == {"status": "ok"} def test_predict_endpoint(): payload = { "text": "The government passed a new healthcare bill today." } response = client.post("/predict", json=payload) assert response.status_code == 200 data = response.json() assert "prediction" in data assert "confidence" in data assert "latency_ms" in data assert data["prediction"] in [0, 1] assert 0.0 <= data["confidence"] <= 1.0 assert data["latency_ms"] > 0