osint-dashboard/tests/test_health_ready.py

34 lines
865 B
Python
Raw Normal View History

"""Liveness stays up; readiness/freshness is explicit."""
from __future__ import annotations
import asyncio
import httpx
from main import app
BASE = "http://test"
async def _get(path: str) -> httpx.Response:
transport = httpx.ASGITransport(app=app)
async with httpx.AsyncClient(transport=transport, base_url=BASE) as client:
return await client.get(path)
def test_health_includes_checks_even_when_db_ok(monkeypatch):
"""HUD must be able to show degraded without docker killing the container."""
body = asyncio.run(_get("/api/health")).json()
assert "status" in body
assert "checks" in body
assert "db" in body["checks"]
def test_ready_endpoint_exists():
resp = asyncio.run(_get("/api/ready"))
assert resp.status_code in (200, 503)
body = resp.json()
assert "checks" in body
assert "status" in body