Kairo-Jinkendo/backend/tests/test_ap14e_graph_profiles.py
Lars 1fa61b2dac
Some checks failed
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 2m18s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
AP1.4e: Methodenprofile am Gate-Graph.
generic_operating ohne harte Blockade, Reifegrad-Methoden mit Erfuellungsgrad; Attention gate_graph_blocked fuer gate-orientierte Methoden.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 08:06:42 +02:00

71 lines
2.3 KiB
Python

"""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