info-tech-canon/tests/test_import_reviews.py
tegwick 361c944325
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Introduce identity model and reconcile upstream imports
Assistant: codex
Assistant-Model: gpt-6-astra
Assistant-Session: 01a070b5-4994-7271-bd8b-7c3dbcedec4b
2026-09-05 22:11:46 +02:00

45 lines
1.9 KiB
Python

from types import SimpleNamespace
import yaml
from info_tech_canon.import_reviews import reviewed_import_cycles
def fixture(tmp_path):
(tmp_path / "validation").mkdir()
(tmp_path / "review.md").write_text("Distinct concept owners reviewed.")
edges = [["a", "uses", "b"], ["b", "uses", "a"]]
(tmp_path / "validation/model-import-reviews.yaml").write_text(yaml.safe_dump(
{"reviews": [{"boundary_review": "review.md", "edges": edges}]}))
return [SimpleNamespace(id="a", kind="model", relationships=[{"type": "uses", "target": "b"}]),
SimpleNamespace(id="b", kind="model", relationships=[{"type": "uses", "target": "a"}])]
def test_exact_review_preserves_reciprocal_imports(tmp_path):
artifacts = fixture(tmp_path)
assert len(reviewed_import_cycles(artifacts, tmp_path)) == 1
assert artifacts[0].relationships == [{"type": "uses", "target": "b"}]
def test_new_internal_edge_or_type_is_not_excused(tmp_path):
artifacts = fixture(tmp_path)
artifacts[0].relationships.append({"type": "defines", "target": "b"})
assert reviewed_import_cycles(artifacts, tmp_path) is None
def test_new_component_member_is_not_excused(tmp_path):
artifacts = fixture(tmp_path)
artifacts[0].relationships.append({"type": "uses", "target": "c"})
artifacts.append(SimpleNamespace(id="c", kind="model", relationships=[{"type": "uses", "target": "a"}]))
assert reviewed_import_cycles(artifacts, tmp_path) is None
def test_missing_rationale_is_not_excused(tmp_path):
artifacts = fixture(tmp_path)
(tmp_path / "review.md").unlink()
assert reviewed_import_cycles(artifacts, tmp_path) is None
def test_unreviewed_second_cycle_is_not_excused(tmp_path):
artifacts = fixture(tmp_path)
artifacts.append(SimpleNamespace(id="c", kind="model", relationships=[{"type": "uses", "target": "c"}]))
assert reviewed_import_cycles(artifacts, tmp_path) is None