2026-07-25 10:27:40 +02:00
|
|
|
"""AP2.3e — Method compatibility validation."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from tests.factories import provision_user_in_tenant
|
|
|
|
|
from tests.test_initiatives_actions import _auth, _create_initiative, _login
|
|
|
|
|
|
|
|
|
|
|
2026-07-26 15:01:40 +02:00
|
|
|
def test_update_method_queue_pull_on_support_queue_ok(client):
|
2026-07-25 10:27:40 +02:00
|
|
|
user = provision_user_in_tenant(tenant_role="member")
|
|
|
|
|
token = _login(client, user)
|
|
|
|
|
|
|
|
|
|
created = _create_initiative(
|
|
|
|
|
client,
|
|
|
|
|
token,
|
2026-07-26 15:01:40 +02:00
|
|
|
title="Queue Override",
|
|
|
|
|
archetype_key="initiative.support_queue",
|
2026-07-25 10:27:40 +02:00
|
|
|
)
|
|
|
|
|
initiative_id = created.json()["id"]
|
|
|
|
|
|
|
|
|
|
res = client.patch(
|
|
|
|
|
f"/api/steering/initiatives/{initiative_id}/context",
|
|
|
|
|
json={"method_key": "queue_pull"},
|
|
|
|
|
headers=_auth(token),
|
|
|
|
|
)
|
|
|
|
|
assert res.status_code == 200
|
|
|
|
|
assert res.json()["method_key"] == "queue_pull"
|
|
|
|
|
|
|
|
|
|
|
2026-07-26 15:01:40 +02:00
|
|
|
def test_update_method_queue_pull_on_linear_rejected(client):
|
|
|
|
|
user = provision_user_in_tenant(tenant_role="member")
|
|
|
|
|
token = _login(client, user)
|
|
|
|
|
|
|
|
|
|
created = _create_initiative(
|
|
|
|
|
client,
|
|
|
|
|
token,
|
|
|
|
|
title="Linear Override",
|
|
|
|
|
archetype_key="initiative.linear_project",
|
|
|
|
|
)
|
|
|
|
|
initiative_id = created.json()["id"]
|
|
|
|
|
|
|
|
|
|
res = client.patch(
|
|
|
|
|
f"/api/steering/initiatives/{initiative_id}/context",
|
|
|
|
|
json={"method_key": "queue_pull"},
|
|
|
|
|
headers=_auth(token),
|
|
|
|
|
)
|
|
|
|
|
assert res.status_code == 400
|
|
|
|
|
assert "kompatibel" in res.json()["detail"].lower()
|
|
|
|
|
|
|
|
|
|
|
2026-07-25 10:27:40 +02:00
|
|
|
def test_update_method_maturity_on_product_rejected(client):
|
|
|
|
|
user = provision_user_in_tenant(tenant_role="member")
|
|
|
|
|
token = _login(client, user)
|
|
|
|
|
|
|
|
|
|
created = _create_initiative(
|
|
|
|
|
client,
|
|
|
|
|
token,
|
|
|
|
|
title="Product Block",
|
|
|
|
|
archetype_key="initiative.product",
|
|
|
|
|
)
|
|
|
|
|
initiative_id = created.json()["id"]
|
|
|
|
|
|
|
|
|
|
res = client.patch(
|
|
|
|
|
f"/api/steering/initiatives/{initiative_id}/context",
|
|
|
|
|
json={"method_key": "maturity_progression"},
|
|
|
|
|
headers=_auth(token),
|
|
|
|
|
)
|
|
|
|
|
assert res.status_code == 400
|
|
|
|
|
assert "kompatibel" in res.json()["detail"].lower()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_operating_context_reflects_method_slice_intersection(client):
|
|
|
|
|
user = provision_user_in_tenant(tenant_role="member")
|
|
|
|
|
token = _login(client, user)
|
|
|
|
|
|
|
|
|
|
created = _create_initiative(
|
|
|
|
|
client,
|
|
|
|
|
token,
|
2026-07-26 15:01:40 +02:00
|
|
|
title="Queue Support",
|
|
|
|
|
archetype_key="initiative.support_queue",
|
2026-07-25 10:27:40 +02:00
|
|
|
)
|
|
|
|
|
initiative_id = created.json()["id"]
|
|
|
|
|
|
|
|
|
|
client.patch(
|
|
|
|
|
f"/api/steering/initiatives/{initiative_id}/context",
|
|
|
|
|
json={"method_key": "queue_pull"},
|
|
|
|
|
headers=_auth(token),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
ctx = client.get(
|
|
|
|
|
f"/api/initiatives/{initiative_id}/operating-context",
|
|
|
|
|
headers=_auth(token),
|
|
|
|
|
)
|
|
|
|
|
assert ctx.status_code == 200
|
|
|
|
|
slices = ctx.json()["data_slices"]
|
|
|
|
|
assert "backlog" in slices
|
|
|
|
|
assert "work_cycles" not in slices
|