35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
|
|
"""Unit tests for plan/ist overlay (AP1.14)."""
|
||
|
|
|
||
|
|
from steering.graph.plan_ist import _ist_deviation_diff, _structural_diff
|
||
|
|
|
||
|
|
|
||
|
|
def test_structural_diff_detects_added_gate():
|
||
|
|
baseline = {"items": [{"id": "a", "title": "A", "goal_description": "", "sort_order": 0}], "dependencies": [], "criteria": []}
|
||
|
|
current = {
|
||
|
|
"items": [
|
||
|
|
{"id": "a", "title": "A", "goal_description": "", "sort_order": 0},
|
||
|
|
{"id": "b", "title": "B", "goal_description": "", "sort_order": 1},
|
||
|
|
],
|
||
|
|
"dependencies": [],
|
||
|
|
"criteria": [],
|
||
|
|
}
|
||
|
|
diffs = _structural_diff(baseline, current)
|
||
|
|
assert any(d["kind"] == "gate_added" and d["item_id"] == "b" for d in diffs)
|
||
|
|
|
||
|
|
|
||
|
|
def test_ist_deviation_detects_reached_gate():
|
||
|
|
items = [{"id": "g1", "title": "Gate", "status": "reached"}]
|
||
|
|
diffs = _ist_deviation_diff(items=items, criteria_by_item={"g1": []})
|
||
|
|
assert any(d["kind"] == "ist_gate_status" for d in diffs)
|
||
|
|
|
||
|
|
|
||
|
|
def test_ist_deviation_detects_waived_criterion():
|
||
|
|
items = [{"id": "g1", "title": "Gate", "status": "active"}]
|
||
|
|
criteria = {
|
||
|
|
"g1": [
|
||
|
|
{"id": "c1", "title": "Kriterium", "status": "waived", "criterion_kind": "manual"}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
diffs = _ist_deviation_diff(items=items, criteria_by_item=criteria)
|
||
|
|
assert any(d["kind"] == "ist_criterion_waived" for d in diffs)
|