from fastapi.testclient import TestClient from hypothesis import given, settings from hypothesis import strategies as st from main import app client = TestClient(app) def test_liveness_ok(): response = client.get("/health/live") assert response.status_code == 200 assert response.text == "live" def test_readiness_ok(): response = client.get("/health/ready") assert response.status_code == 200 assert response.text == "ready" def test_detailed_health_pass(): resp = client.get("/health") assert resp.status_code == 200 body = resp.json() assert body["status"] == "pass" assert isinstance(body["checks"], dict) @given(st.text(min_size=0, max_size=16)) @settings(max_examples=10) def test_health_resilient_to_query_noise(noise: str): resp = client.get("/health/live", params={"noise": noise}) assert resp.status_code == 200 assert resp.text == "live"