Estimates stored as batches of risks in the domain's database: models store and run --store; a kit file is read as dbt's only when its producer is dbt

This commit is contained in:
2026-11-06 00:21:53 -06:00
parent 22d1fda0f3
commit 761b5b03bc
9 changed files with 236 additions and 15 deletions
+16 -1
View File
@@ -7,7 +7,7 @@ Fixtures: none; each test builds its own small table or file.
import pyarrow as pa
import pytest
from models.io.lineage import file_sha256, matches, registered_name, require_match, table_sha256
from models.io.lineage import cohort_reference, file_sha256, matches, registered_name, require_match, table_sha256
def test_a_table_hashes_by_its_rows_not_its_metadata():
@@ -47,3 +47,18 @@ def test_a_mismatch_is_refused_with_both_sides():
def test_models_are_registered_as_domain_and_scenario():
"""Pins down: the name runs and versions share. Fails if the convention changes on one side only."""
assert registered_name("cacu", "cin2_logistic") == "cacu-cin2_logistic"
@pytest.mark.parametrize("metadata, expected", [
({"url": "u", "producer": "dbt", "build": "4"}, ("dbt", "4")),
({"url": "u", "producer": "kit", "armado_id": "2"}, ("kit", "2")),
({"url": "u", "producer": "kit build, timeline from dbt view", "armado_id": "1"}, ("kit", "1")),
({"url": "u", "armado_id": "3"}, ("kit", "3")),
])
def test_a_file_is_dbts_only_when_its_producer_says_dbt(metadata, expected):
"""Pins down: a cohort file's source is dbt only for `producer: dbt`; any other producer, or none, is a kit build
numbered by `armado_id`. Fails if an older kit file with a descriptive producer is read as dbt's and loses its
`armado_id`."""
reference = cohort_reference(metadata, "f" * 64)
assert (reference["cohort.source"], reference["cohort.build"]) == expected