Kairo-Jinkendo/backend/tests/test_ap14e_graph_profiles.py

71 lines
2.3 KiB
Python
Raw Normal View History

"""Unit tests for graph method profiles (AP1.4e)."""
from steering.graph.profiles import get_graph_profile
from steering.graph.roadmap_engine import (
apply_graph_method_profile,
compute_initiative_graph_state,
compute_initiative_graph_state_with_profile,
)
def _item(item_id: str, status: str = "planned", **kwargs):
return {
"id": item_id,
"status": status,
"sort_order": kwargs.get("sort_order", 0),
"sequencing_mode": kwargs.get("sequencing_mode", "sequential"),
}
def test_generic_operating_does_not_enforce_blocking():
items = [
_item("first", "planned", sort_order=0),
_item("second", "planned", sort_order=1),
]
state = compute_initiative_graph_state_with_profile(
items=items,
dependencies=[],
method_key="generic_operating",
)
assert state["graph_profile"]["enforce_gate_blocking"] is False
assert state["items"]["second"]["would_block"] is True
assert state["items"]["second"]["blocked"] is False
assert state["items"]["second"]["ready"] is True
assert state["blocked_items"] == []
def test_product_milestone_enforces_blocking():
items = [
_item("first", "planned", sort_order=0),
_item("second", "planned", sort_order=1),
]
state = compute_initiative_graph_state_with_profile(
items=items,
dependencies=[],
method_key="product_milestone_driven",
)
assert state["graph_profile"]["enforce_gate_blocking"] is True
assert state["items"]["second"]["blocked"] is True
assert "second" in state["blocked_items"]
def test_maturity_progression_emphasizes_fulfillment():
profile = get_graph_profile("maturity_progression")
assert profile.emphasize_fulfillment is True
assert profile.enforce_gate_blocking is False
def test_initiative_fulfillment_ratio_average():
items = [_item("a", "active"), _item("b", "active")]
base = compute_initiative_graph_state(
items=items,
dependencies=[],
criteria_progress={
"a": {"total": 2, "closed": 2, "open": 0},
"b": {"total": 4, "closed": 2, "open": 2},
},
)
profile = get_graph_profile("maturity_progression")
state = apply_graph_method_profile(base, profile)
assert state["initiative_fulfillment_ratio"] == 0.75