Refine health checks and add polling animation

This commit is contained in:
2025-11-27 11:43:35 +01:00
parent c841e27c30
commit 25d80f5723
18 changed files with 499 additions and 219 deletions

View File

@@ -6,25 +6,27 @@ from main import app
client = TestClient(app)
def test_liveness_ok():
response = client.get("/healthz")
response = client.get("/health/live")
assert response.status_code == 200
data = response.json()
assert data["status"] == "ok"
assert data["service"] == "backend"
assert data["environment"]
assert response.text == "live"
def test_readiness_ok():
response = client.get("/readyz")
response = client.get("/health/ready")
assert response.status_code == 200
assert response.json()["status"] == "ok"
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("/healthz", params={"noise": noise})
resp = client.get("/health/live", params={"noise": noise})
assert resp.status_code == 200
assert resp.json()["status"] == "ok"
assert resp.text == "live"