Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b660c77191 | |||
| a15ca94564 |
+17
-6
@@ -29,15 +29,26 @@ def test_listar_indicadores(client):
|
|||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
lista = response.get_json()
|
lista = response.get_json()
|
||||||
assert [fila["id"] for fila in lista] == sorted(DEFINICIONES)
|
visibles = [id_ for id_, medida in DEFINICIONES.items() if not medida.extension.publicacion.oculto]
|
||||||
fila = next(fila for fila in lista if fila["id"] == INDICADOR)
|
assert [fila["id"] for fila in lista] == sorted(visibles)
|
||||||
medida = DEFINICIONES[INDICADOR]
|
for fila in lista:
|
||||||
|
medida = DEFINICIONES[fila["id"]]
|
||||||
assert fila["titulo"] == medida.title
|
assert fila["titulo"] == medida.title
|
||||||
assert fila["contrato"] == medida.extension.contrato
|
assert fila["contrato"] == medida.extension.contrato
|
||||||
assert fila["figuras"] == figuras_de(medida) == [FIGURA]
|
assert fila["figuras"] == figuras_de(medida)
|
||||||
assert fila["tipos_periodo"] == ["semestre", "mes"]
|
assert fila["tipos_periodo"] == ["semestre", "mes"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_los_ocultos_no_salen_en_el_catalogo_pero_responden(client):
|
||||||
|
"""Provisional (oct 2026): cacu_eu7_anormal y cacu_eu8 no se muestran."""
|
||||||
|
ocultos = {"cacu_eu7_anormal", "cacu_eu8"}
|
||||||
|
ids = {fila["id"] for fila in client.get(f"/{PROYECTO}/indicadores").get_json()}
|
||||||
|
|
||||||
|
assert ids == set(DEFINICIONES) - ocultos
|
||||||
|
for indicador in ocultos:
|
||||||
|
assert client.get(f"/{PROYECTO}/indicadores/{indicador}/metadatos").status_code == 200
|
||||||
|
|
||||||
|
|
||||||
def test_figura_con_semestres(client):
|
def test_figura_con_semestres(client):
|
||||||
response = _figura(client, query=f"?periodos={','.join(SEMESTRES)}&tema=oscuro")
|
response = _figura(client, query=f"?periodos={','.join(SEMESTRES)}&tema=oscuro")
|
||||||
|
|
||||||
@@ -148,8 +159,8 @@ def test_el_catalogo_trae_lo_necesario_para_pedir_lo_demas(client):
|
|||||||
lista = client.get(f"/{PROYECTO}/indicadores").get_json()
|
lista = client.get(f"/{PROYECTO}/indicadores").get_json()
|
||||||
|
|
||||||
assert all(set(fila) == CATALOGO for fila in lista)
|
assert all(set(fila) == CATALOGO for fila in lista)
|
||||||
fila = next(fila for fila in lista if fila["id"] == INDICADOR)
|
for fila in lista:
|
||||||
medida = DEFINICIONES[INDICADOR]
|
medida = DEFINICIONES[fila["id"]]
|
||||||
assert (fila["version"], fila["unidad"], fila["sentido"]) == (medida.version, medida.basis, medida.improvementNotation)
|
assert (fila["version"], fila["unidad"], fila["sentido"]) == (medida.version, medida.basis, medida.improvementNotation)
|
||||||
assert fila["estratos"] == medida.extension.estratos
|
assert fila["estratos"] == medida.extension.estratos
|
||||||
|
|
||||||
|
|||||||
+17
-6
@@ -29,15 +29,26 @@ def test_listar_indicadores(client):
|
|||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
lista = response.get_json()
|
lista = response.get_json()
|
||||||
assert [fila["id"] for fila in lista] == sorted(DEFINICIONES)
|
visibles = [id_ for id_, medida in DEFINICIONES.items() if not medida.extension.publicacion.oculto]
|
||||||
fila = next(fila for fila in lista if fila["id"] == INDICADOR)
|
assert [fila["id"] for fila in lista] == sorted(visibles)
|
||||||
medida = DEFINICIONES[INDICADOR]
|
for fila in lista:
|
||||||
|
medida = DEFINICIONES[fila["id"]]
|
||||||
assert fila["titulo"] == medida.title
|
assert fila["titulo"] == medida.title
|
||||||
assert fila["contrato"] == medida.extension.contrato
|
assert fila["contrato"] == medida.extension.contrato
|
||||||
assert fila["figuras"] == figuras_de(medida) == [FIGURA]
|
assert fila["figuras"] == figuras_de(medida)
|
||||||
assert fila["tipos_periodo"] == ["semestre", "mes"]
|
assert fila["tipos_periodo"] == ["semestre", "mes"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_los_ocultos_no_salen_en_el_catalogo_pero_responden(client):
|
||||||
|
"""Provisional (oct 2026): cama_confirmacion_birads45 y cama_eu8 no se muestran."""
|
||||||
|
ocultos = {"cama_confirmacion_birads45", "cama_eu8"}
|
||||||
|
ids = {fila["id"] for fila in client.get(f"/{PROYECTO}/indicadores").get_json()}
|
||||||
|
|
||||||
|
assert ids == set(DEFINICIONES) - ocultos
|
||||||
|
for indicador in ocultos:
|
||||||
|
assert client.get(f"/{PROYECTO}/indicadores/{indicador}/metadatos").status_code == 200
|
||||||
|
|
||||||
|
|
||||||
def test_figura_con_semestres(client):
|
def test_figura_con_semestres(client):
|
||||||
response = _figura(client, query=f"?periodos={','.join(SEMESTRES)}&tema=oscuro")
|
response = _figura(client, query=f"?periodos={','.join(SEMESTRES)}&tema=oscuro")
|
||||||
|
|
||||||
@@ -135,8 +146,8 @@ def test_el_catalogo_trae_lo_necesario_para_pedir_lo_demas(client):
|
|||||||
lista = client.get(f"/{PROYECTO}/indicadores").get_json()
|
lista = client.get(f"/{PROYECTO}/indicadores").get_json()
|
||||||
|
|
||||||
assert all(set(fila) == CATALOGO for fila in lista)
|
assert all(set(fila) == CATALOGO for fila in lista)
|
||||||
fila = next(fila for fila in lista if fila["id"] == INDICADOR)
|
for fila in lista:
|
||||||
medida = DEFINICIONES[INDICADOR]
|
medida = DEFINICIONES[fila["id"]]
|
||||||
assert (fila["version"], fila["unidad"], fila["sentido"]) == (medida.version, medida.basis, medida.improvementNotation)
|
assert (fila["version"], fila["unidad"], fila["sentido"]) == (medida.version, medida.basis, medida.improvementNotation)
|
||||||
assert fila["estratos"] == medida.extension.estratos
|
assert fila["estratos"] == medida.extension.estratos
|
||||||
|
|
||||||
|
|||||||
+14
-2
@@ -9,7 +9,7 @@ PERIODOS = ",".join(fixtures.PERIODOS)
|
|||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def client(tmp_path_factory):
|
def client(tmp_path_factory):
|
||||||
"""Una base de TEA temporal, con los 18 indicadores calculados, por `TEA_DATABASE_URL`."""
|
"""Una base de TEA temporal, con los 20 indicadores calculados (16 en el catálogo), por `TEA_DATABASE_URL`."""
|
||||||
# Dentro de la fixture: la configuración de Persistance se lee al importarla,
|
# Dentro de la fixture: la configuración de Persistance se lee al importarla,
|
||||||
# y test_app.py debe alcanzar a fijar CACU_DATABASE_URL antes.
|
# y test_app.py debe alcanzar a fijar CACU_DATABASE_URL antes.
|
||||||
from persistance.db import get_tea_engine
|
from persistance.db import get_tea_engine
|
||||||
@@ -42,7 +42,8 @@ def test_listar_indicadores(client):
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
lista = response.get_json()
|
lista = response.get_json()
|
||||||
assert [fila["id"] for fila in lista] == sorted(DEFINICIONES)
|
visibles = [id_ for id_, medida in DEFINICIONES.items() if not medida.extension.publicacion.oculto]
|
||||||
|
assert [fila["id"] for fila in lista] == sorted(visibles)
|
||||||
for fila in lista:
|
for fila in lista:
|
||||||
medida = DEFINICIONES[fila["id"]]
|
medida = DEFINICIONES[fila["id"]]
|
||||||
assert fila["titulo"] == medida.title
|
assert fila["titulo"] == medida.title
|
||||||
@@ -50,6 +51,17 @@ def test_listar_indicadores(client):
|
|||||||
assert fila["figuras"] == figuras_de(medida)
|
assert fila["figuras"] == figuras_de(medida)
|
||||||
|
|
||||||
|
|
||||||
|
def test_los_ocultos_no_salen_en_el_catalogo_pero_responden(client):
|
||||||
|
"""Provisional (oct 2026): K01, K08, M04 y M15 no se muestran; quedan 16 en el catálogo."""
|
||||||
|
ocultos = {"K01_evaluacion_3_meses", "K08_eeg_sueno", "M04_dias_entrevista_ados2", "M15_grado_hipoacusia"}
|
||||||
|
ids = {fila["id"] for fila in client.get("/tea/indicadores").get_json()}
|
||||||
|
|
||||||
|
assert len(ids) == 16
|
||||||
|
assert not ids & ocultos
|
||||||
|
assert {"M21_diagnosticados_con_eeg", "M22_diagnosticados_sin_eeg"} <= ids
|
||||||
|
assert client.get("/tea/indicadores/K01_evaluacion_3_meses/metadatos").status_code == 200
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("indicador", sorted(DEFINICIONES))
|
@pytest.mark.parametrize("indicador", sorted(DEFINICIONES))
|
||||||
def test_figura_de_cada_indicador(client, indicador):
|
def test_figura_de_cada_indicador(client, indicador):
|
||||||
for figura in figuras_de(DEFINICIONES[indicador]):
|
for figura in figuras_de(DEFINICIONES[indicador]):
|
||||||
|
|||||||
@@ -91,7 +91,12 @@ def registrar_indicadores(
|
|||||||
tablas = tablas_de(proyecto)
|
tablas = tablas_de(proyecto)
|
||||||
|
|
||||||
def listar_indicadores():
|
def listar_indicadores():
|
||||||
return _json([resumen_de(id_, medida) for id_, medida in definiciones.items()])
|
# Los marcados `oculto` en su TOML no salen en el catálogo; su id sigue respondiendo.
|
||||||
|
return _json([
|
||||||
|
resumen_de(id_, medida)
|
||||||
|
for id_, medida in definiciones.items()
|
||||||
|
if not medida.extension.publicacion.oculto
|
||||||
|
])
|
||||||
|
|
||||||
def _periodos_o_los_que_haya(sesion: Session, medida: Measure, periodos: list[str]) -> list[str]:
|
def _periodos_o_los_que_haya(sesion: Session, medida: Measure, periodos: list[str]) -> list[str]:
|
||||||
"""Los pedidos; sin pedir ninguno, los que tienen reporte del primer tipo que publica."""
|
"""Los pedidos; sin pedir ninguno, los que tienen reporte del primer tipo que publica."""
|
||||||
|
|||||||
Reference in New Issue
Block a user