From 8e5a7e3b81e8210cc5eb85f494e5646d235048f8 Mon Sep 17 00:00:00 2001 From: edgar Date: Sun, 22 Nov 2026 00:28:43 -0600 Subject: [PATCH] test(cacu): the timeline's birth and death rows come from persona CaCu's timeline now holds the patient's birth and death like CaMa's, so the comparison with the kit's rows leaves them out along with the inferred procedures. --- tests/test_orquestacion_timeline.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/test_orquestacion_timeline.py b/tests/test_orquestacion_timeline.py index acfda7a..b24e7f7 100644 --- a/tests/test_orquestacion_timeline.py +++ b/tests/test_orquestacion_timeline.py @@ -15,7 +15,9 @@ from pathlib import Path import pytest CORTE = date(2025, 12, 31) -INFERRED = {"colposcopia", "tratamiento", "citologia_de_vigilancia", "diagnostico", "antecedente", "orden_biopsia"} +# What dbt adds to the kit's timeline: the procedures it infers and the patient's birth and death, from `persona`. +ADDED = {"colposcopia", "tratamiento", "citologia_de_vigilancia", "diagnostico", "antecedente", "orden_biopsia", + "nacimiento", "defuncion"} KIT_ROWS = Path(__file__).parent / "fixtures" / "kit_cacu_timeline.json" @@ -38,18 +40,18 @@ def kit_rows(): def as_kit(rows) -> list[dict]: - """Rows as the snapshot keeps them: text values, no load time, without the inferred procedures.""" + """Rows as the snapshot keeps them: text values, no load time, without the rows dbt adds.""" return [{k: None if v is None else str(v) for k, v in row.items() if k != "conocida_en"} - for row in rows if row["tipo"] not in INFERRED] + for row in rows if row["tipo"] not in ADDED] def test_the_timeline_is_the_kit_s_plus_the_inferred_procedures(loaded, kit_rows): """Pins down: the wired repository reads dbt's view, which holds every row the kit's timeline held, in its - order and with a date as `fecha`, plus inferred procedures. Fails if the orchestration binds another query, or - the view stops giving one of the kit's rows.""" + order and with a date as `fecha`, plus the inferred procedures and the patient's birth and death. Fails if the + orchestration binds another query, or the view stops giving one of the kit's rows.""" rows = loaded.ctx.repos.silver.timeline.read(until=CORTE) assert as_kit(rows) == kit_rows - assert {row["tipo"] for row in rows} & INFERRED + assert {row["tipo"] for row in rows} & ADDED assert all(isinstance(row["fecha"], date) for row in rows)