uv project on Python 3.14 with Ruff (incl. DTZ), pyright strict, and import-linter contracts: composition root above domains above platform, each domain reachable from others only through its `service` module, and `bots/` forbidden from importing `hapi`. `just dev/test/lint` recipes and pre-commit running the same checks plus gitleaks. `just` and `pre-commit` are dev dependencies, so uv is the only tool needed outside the venv. `hapi serve` runs the public API (:8000) and the internal probe listener (:8081) as two uvicorn servers in one event loop (ADR-0009); `/livez` is constant and served only on :8081. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
880 B
Python
27 lines
880 B
Python
"""The internal `:8081` listener serves unauthenticated probes the public API never does."""
|
|
|
|
from httpx import ASGITransport, AsyncClient
|
|
|
|
from hapi.app import create_api_app, create_probe_app
|
|
|
|
|
|
async def test_livez_returns_constant_ok_on_the_probe_listener() -> None:
|
|
async with AsyncClient(
|
|
transport=ASGITransport(app=create_probe_app()), base_url="http://probes"
|
|
) as client:
|
|
first = await client.get("/livez")
|
|
second = await client.get("/livez")
|
|
|
|
assert first.status_code == 200
|
|
assert first.json() == {"status": "ok"}
|
|
assert second.json() == first.json()
|
|
|
|
|
|
async def test_livez_is_not_served_on_the_public_api() -> None:
|
|
async with AsyncClient(
|
|
transport=ASGITransport(app=create_api_app()), base_url="http://api"
|
|
) as client:
|
|
response = await client.get("/livez")
|
|
|
|
assert response.status_code == 404
|