fdce3a5f49
Export (GET /models/{domain}/export) writes a deterministic zip of chosen versions with a manifest of SHA-256s, after the domain guard (TEA: n_reference >= 5, no study codes, dates or paths). Import (POST /models/{domain}/import, Dagster job import_bundle) stages the upload, checks its SHA-256 and that the operator listed it in $DATA_DIR/bundles/trusted (403 otherwise), verifies every file against the manifest and registers new candidate versions with lineage tags; duplicates are skipped.
Checks: ruff, import-linter, openapi diff; compose: 43 passed (test_bundles, test_runs, test_bundle, test_core_bundle_guard); ng build clean.
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
import pytest
|
|
|
|
from core.domains import Domain, part
|
|
from core.tea.bundle import guard
|
|
from persistance import bundle, registry
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("metrics", "problems"),
|
|
[
|
|
({"n_reference": 4}, ["reference group of 4 children is under 5"]),
|
|
({"n_reference": 5}, []),
|
|
({}, ["cannot tell the reference group size (no n_reference metric)"]),
|
|
],
|
|
)
|
|
def test_reference_group_size(metrics, problems):
|
|
assert guard({"metrics": metrics, "params": {}, "tags": {}, "reports": {}}) == problems
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("field", "key", "where", "value"),
|
|
[
|
|
("params", "date", "param date", "2026-11-28"),
|
|
("tags", "study", "tag study", "eeg_12"),
|
|
("reports", "technical_validation", "report technical_validation", "/home/x"),
|
|
],
|
|
)
|
|
def test_guard_names_where_it_found_protected_values(field, key, where, value):
|
|
version = {"metrics": {"n_reference": 5}, "params": {}, "tags": {}, "reports": {}}
|
|
version[field][key] = value
|
|
match = "/home/" if value == "/home/x" else value
|
|
assert guard(version) == [f"{where} holds a study code, date or path ({match!r})"]
|
|
|
|
|
|
def test_clinical_validation_is_not_passed_and_cacu_has_no_guard():
|
|
reports = {"clinical_validation": ("review.txt", b"2026-11-28 eeg_12 /home/x")}
|
|
snapshot = registry.Snapshot("tea.curve_x", 1, 0, {}, {"n_reference": 5}, {}, reports, {})
|
|
assert bundle.guard(Domain.TEA, snapshot) == []
|
|
assert part(Domain.CACU, "bundle") is None
|
|
assert bundle.guard(Domain.CACU, snapshot) == []
|