35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""`/health` is the load-balancer probe — it must keep working even when the
|
|
engine bridge is absent (Phase 0 default)."""
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
def test_health_returns_ok(client: TestClient) -> None:
|
|
response = client.get("/health")
|
|
assert response.status_code == 200
|
|
|
|
payload = response.json()
|
|
assert payload["status"] == "ok"
|
|
# engine_available reflects the actual build environment — just assert the field exists and is a bool
|
|
assert isinstance(payload["engine_available"], bool), (
|
|
f"Expected engine_available to be a bool, got: {payload['engine_available']!r}"
|
|
)
|
|
assert "version" in payload
|
|
assert "environment" in payload
|
|
|
|
|
|
def test_health_does_not_require_engine(client: TestClient) -> None:
|
|
"""Regression guard: importing the app and hitting /health must not
|
|
transitively import the pybind11 module (which doesn't exist yet)."""
|
|
import sys
|
|
|
|
had_pdfengine = "pdfengine" in sys.modules
|
|
pdfengine_module = sys.modules.pop("pdfengine", None)
|
|
try:
|
|
response = client.get("/health")
|
|
assert response.status_code == 200
|
|
assert "pdfengine" not in sys.modules
|
|
finally:
|
|
if had_pdfengine and pdfengine_module is not None:
|
|
sys.modules["pdfengine"] = pdfengine_module
|