Follow-up list and patient risk routes are always registered; en_dev() is deprecated

This commit is contained in:
2026-11-09 11:30:28 -06:00
parent 0f00a975fa
commit 0cbe390b25
5 changed files with 40 additions and 51 deletions
+8 -20
View File
@@ -2,9 +2,8 @@
shape the WebApp's contract reads (`RiesgoPacienteCacu`), and its 404. The reads behind it are Persistance's, tested
there.
Fixtures: `client`, a DEV client over the kit's CaCu demonstration database (`conftest.cliente_de`) plus `seeded`:
a surveillance build with two of its patients, one of them with variables and a confirmed batch; `fuera_de_dev`, the
same app without `DEV_REVISION`.
Fixtures: `client`, the app without `DEV_REVISION` over the kit's CaCu demonstration database (`conftest.cliente_de`)
plus `seeded`: a surveillance build with two of its patients, one of them with variables and a confirmed batch.
"""
from datetime import date, datetime, timezone
@@ -19,8 +18,9 @@ HORIZON_KEYS = {"horizonte_anios", "probabilidad", "ic_bajo", "ic_alto", "estado
@pytest.fixture(scope="module")
def client(tmp_path_factory):
"""The app over the CaCu demonstration database, with no `DEV_REVISION` in the environment."""
with pytest.MonkeyPatch.context() as mp:
mp.setenv("DEV_REVISION", "prueba")
mp.delenv("DEV_REVISION", raising=False)
yield from cliente_de("cacu", tmp_path_factory)
@@ -55,17 +55,11 @@ def seeded(client):
return scored, unscored, outside
@pytest.fixture(scope="module")
def fuera_de_dev(tmp_path_factory):
with pytest.MonkeyPatch.context() as mp:
mp.delenv("DEV_REVISION", raising=False)
yield from cliente_de("cacu", tmp_path_factory)
def test_a_scored_member_has_the_contracts_shape(client, seeded):
"""Pins down: the body has `simulado`, `cohorte` and `riesgo` with exactly the contract's fields, the horizons in
ascending order, probabilities in 0..1 and the date as ISO-8601 UTC. Fails if a field is renamed or dropped, which
would break the WebApp's validation."""
"""Pins down: without `DEV_REVISION` the route exists, and the body has `simulado`, `cohorte` and `riesgo` with
exactly the contract's fields, the horizons in ascending order, probabilities in 0..1 and the date as ISO-8601 UTC.
Fails if the route depends on an environment variable again, or if a field is renamed or dropped, which would break
the WebApp's validation."""
response = client.get(f"/cacu/pacientes/{seeded[0]}/riesgo")
body = response.get_json()
@@ -91,9 +85,3 @@ def test_a_member_without_a_confirmed_batch_and_a_non_member(client, seeded):
def test_an_unknown_patient_is_404(client, seeded):
"""Pins down: a `pac_id` not in `persona` is 404. Fails if it answers with an empty body as if she existed."""
assert client.get("/cacu/pacientes/987654321/riesgo").status_code == 404
def test_outside_dev_the_route_does_not_exist(fuera_de_dev):
"""Pins down: without `DEV_REVISION` the route isn't registered. Fails if patient-level risks are served outside
the simulated DEV deployment."""
assert fuera_de_dev.get("/cacu/pacientes/1/riesgo").status_code == 404