Introduce identity model and reconcile upstream imports
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a070b5-4994-7271-bd8b-7c3dbcedec4b
This commit is contained in:
parent
a2b254786e
commit
361c944325
38 changed files with 1014 additions and 123 deletions
45
tests/test_import_reviews.py
Normal file
45
tests/test_import_reviews.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue