23 lines
788 B
Python
23 lines
788 B
Python
"""Smoke tests for the health endpoints."""
|
|
|
|
from httpx import AsyncClient
|
|
|
|
|
|
async def test_liveness_ok(client: AsyncClient) -> None:
|
|
resp = await client.get("/health")
|
|
assert resp.status_code == 200
|
|
assert resp.json() == {"status": "ok"}
|
|
|
|
|
|
async def test_correlation_id_echoed(client: AsyncClient) -> None:
|
|
resp = await client.get("/health", headers={"X-Correlation-Id": "abc123"})
|
|
assert resp.headers.get("x-correlation-id") == "abc123"
|
|
|
|
|
|
async def test_readiness_reports_checks(client: AsyncClient) -> None:
|
|
# No DB/Redis running in unit env → degraded, but the contract holds.
|
|
resp = await client.get("/health/ready")
|
|
body = resp.json()
|
|
assert set(body["checks"]) == {"database", "redis", "ml"}
|
|
assert body["status"] in {"ready", "degraded"}
|