Kairo-Jinkendo/backend/tests/test_ap20f_work_cycle.py
Lars d1bc725ab5
Some checks failed
Deploy Development / deploy (push) Failing after 48s
Test Suite / pytest-backend (push) Failing after 1s
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 3s
Test Suite / compose-smoke (push) Has been skipped
AP2.0f: work_cycle Zeitbox und actions.work_cycle_id.
RoadmapItem type work_cycle, Sprint-API, agile_iteration Next-Action-Strategie; Steering-Snapshot zeigt active_work_cycle.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-12 12:34:36 +02:00

83 lines
2.6 KiB
Python

"""AP2.0f — work_cycle / Sprint-Zeitbox."""
from __future__ import annotations
from steering.strategies.next_action import register_builtin_strategies
from steering.strategies.next_action.registry import get_next_action_strategy
from tests.factories import provision_user_in_tenant
from tests.test_initiatives_actions import _auth, _create_initiative, _login
def test_agile_iteration_strategy_registered():
register_builtin_strategies()
assert get_next_action_strategy("agile_iteration") is not None
def test_work_cycle_crud_and_action_link(client):
user = provision_user_in_tenant(tenant_role="admin")
token = _login(client, user)
created = _create_initiative(
client,
token,
title="Sprint Product",
archetype_key="initiative.product",
)
initiative_id = created.json()["id"]
cycle = client.post(
f"/api/initiatives/{initiative_id}/work-cycles",
json={"title": "Iteration R1", "goal_description": "AP2.0f", "status": "active"},
headers=_auth(token),
)
assert cycle.status_code == 201
cycle_id = cycle.json()["id"]
assert cycle.json()["status"] == "active"
active = client.get(
f"/api/initiatives/{initiative_id}/work-cycles/active",
headers=_auth(token),
)
assert active.status_code == 200
assert active.json()["id"] == cycle_id
action = client.post(
f"/api/initiatives/{initiative_id}/actions",
json={
"title": "Sprint AP A",
"work_cycle_id": cycle_id,
"status": "ready",
},
headers=_auth(token),
)
assert action.status_code == 201
assert action.json()["work_cycle_id"] == cycle_id
listed = client.get(
f"/api/initiatives/{initiative_id}/work-cycles",
headers=_auth(token),
)
assert listed.status_code == 200
assert any(item["id"] == cycle_id for item in listed.json())
def test_steering_snapshot_includes_active_work_cycle(client):
user = provision_user_in_tenant(tenant_role="member")
token = _login(client, user)
created = _create_initiative(client, token, title="Snapshot Cycle")
initiative_id = created.json()["id"]
client.post(
f"/api/initiatives/{initiative_id}/work-cycles",
json={"title": "Sprint 1", "status": "active"},
headers=_auth(token),
)
snap = client.get(
f"/api/initiatives/{initiative_id}/steering-snapshot",
headers=_auth(token),
)
assert snap.status_code == 200
assert snap.json().get("active_work_cycle")
assert snap.json()["active_work_cycle"]["title"] == "Sprint 1"