The catalog step seeds each domain's mappings, and a mapping is written only if the function still holds

How: `catalog_rows` turns the TOML's study codes, captions and each value's code, label and aliases into the
`catalogo` system's rows; the `catalogs` step adds the system and the forms with no row yet
(`mapeos_nuevos`). `register` normalizes the form and adds the row through `SourceMappingRepository.add`
with `check_stored`, which runs `check_function` on the stored rows of the same form; captions aren't
checked, since one caption may introduce several results. `ctx.repos.silver.mappings` is the domain's
repository.

Implications: the database keeps every mapping across deploys; a person's change is never overwritten, and
a second code for a form in force is refused before it's written. Loads still read the TOML's aliases.
This commit is contained in:
rockdrigo
2026-11-13 15:31:21 -06:00
parent 64d3d721e3
commit 73cbf0cfb8
5 changed files with 138 additions and 11 deletions
+5 -2
View File
@@ -75,7 +75,9 @@ def test_catalogos_deja_en_la_base_las_filas_del_toml(base):
del_toml = {"estudios": len(catalogo.estudios), "resultados": len(catalogo.resultados),
"valores": len(catalogo.valores)}
assert base.run("catalogs")["catalogs"] == {**del_toml, "retirados": 0}
conteos = base.run("catalogs")["catalogs"]
assert conteos.pop("mapeos_nuevos") > 0
assert conteos == {**del_toml, "retirados": 0}
assert filas_del_catalogo(base) == del_toml
@@ -83,7 +85,8 @@ def test_volver_a_correr_catalogos_no_cambia_nada(base):
base.run("catalogs")
antes = filas_del_catalogo(base)
assert base.run("catalogs")["catalogs"]["retirados"] == 0
conteos = base.run("catalogs")["catalogs"]
assert (conteos["retirados"], conteos["mapeos_nuevos"]) == (0, 0)
assert filas_del_catalogo(base) == antes