Conecta demografía y ruta CaCu a persistencia configurada
This commit is contained in:
@@ -14,6 +14,34 @@ LLAVES_DEL_ITEM = {"pac_id", "id_seudonimo", "grupo_edad", "edad_al_corte", "est
|
||||
"dias_toma_diagnostico", "ultima_biopsia", "probabilidades", "prioridad"} # fmt: skip
|
||||
|
||||
|
||||
@pytest.mark.parametrize("fecha", ["1980-01-01", None])
|
||||
def test_demografia_consulta_persona_y_distingue_nulo(monkeypatch, fecha):
|
||||
from datetime import date
|
||||
from flask import Flask
|
||||
from webapi.follow_up import routes
|
||||
|
||||
class Resultado:
|
||||
def first(self):
|
||||
return (date.fromisoformat(fecha) if fecha else None,)
|
||||
|
||||
class Sesion:
|
||||
def execute(self, consulta):
|
||||
assert consulta.compile().params == {"pac_id_1": 42}
|
||||
return Resultado()
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
app = Flask(__name__)
|
||||
app.register_blueprint(routes.follow_up_blueprint(Sesion), url_prefix="/cacu")
|
||||
respuesta = app.test_client().get('/cacu/seguimiento/pacientes/42/demografia')
|
||||
assert respuesta.status_code == 200
|
||||
assert respuesta.json == {"pac_id": "42", "fecha_nacimiento": fecha}
|
||||
|
||||
|
||||
def test_demografia_rechaza_identificador_fuera_de_rango(client):
|
||||
assert client.get('/cacu/seguimiento/pacientes/9223372036854775808/demografia').status_code == 404
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def client(tmp_path_factory):
|
||||
"""La app sobre la base de demostración de CaCu, sin `DEV_REVISION` en el entorno."""
|
||||
@@ -258,13 +286,12 @@ def test_un_caso_es_un_carcinoma_invasor_o_in_situ():
|
||||
assert parametros["cacu"]["seguimiento"]["caso"]["grados"]["valor"] == ["CIS", "CARCINOMA"]
|
||||
|
||||
|
||||
def test_ruta_es_optativa_sintetica_y_se_proyecta_solo_para_la_pagina(client, monkeypatch):
|
||||
from webapi.follow_up import listing, routes
|
||||
def test_ruta_es_optativa_y_se_proyecta_solo_para_la_pagina(client, monkeypatch):
|
||||
from webapi.follow_up import listing
|
||||
|
||||
base = "/cacu/seguimiento?corte=2025-12-31&meses=12&q=%20&page_size=2&page=2"
|
||||
normal = client.get(base).get_json()
|
||||
assert normal["items"] and "ruta_tamizaje" not in normal["items"][0]
|
||||
assert client.get(base + "&incluir=ruta_tamizaje").status_code == 404
|
||||
assert client.get(base + "&incluir=otra").status_code == 400
|
||||
|
||||
llamadas = []
|
||||
@@ -274,7 +301,6 @@ def test_ruta_es_optativa_sintetica_y_se_proyecta_solo_para_la_pagina(client, mo
|
||||
llamadas.append({pac_id for pac_id, _ in tomas.values()})
|
||||
return proyectar(sesion, tomas, corte, tablas)
|
||||
|
||||
monkeypatch.setattr(routes, "_rutas_sinteticas", lambda sesion: True)
|
||||
monkeypatch.setattr(listing, "rutas_de", en_bloque)
|
||||
respuesta = client.get(base + "&incluir=ruta_tamizaje")
|
||||
assert respuesta.status_code == 200
|
||||
@@ -289,5 +315,3 @@ def test_ruta_es_optativa_sintetica_y_se_proyecta_solo_para_la_pagina(client, mo
|
||||
assert client.get(ruta["detalle_url"].replace("corte=" + ruta["corte"], "corte=2026-12-31")).status_code == 404
|
||||
assert client.get(ruta["detalle_url"].replace(f"/rutas/{fila['pac_id']}/", "/rutas/999999/")).status_code == 404
|
||||
assert cuerpo == normal
|
||||
monkeypatch.undo()
|
||||
assert client.get(ruta["detalle_url"]).status_code == 404
|
||||
|
||||
Reference in New Issue
Block a user