All checks were successful
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Successful in 5m3s
Test Suite / lint-backend (push) Successful in 3s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 19s
Test Suite / playwright-smoke (push) Successful in 13s
Gate- und Kit-Übungen legen ein Arbeitspaket plus Schedule an; Today zeigt nur fällige Wochentage, nicht die ganze Gate-Liste. Co-authored-by: Cursor <cursoragent@cursor.com>
148 lines
4.3 KiB
Python
148 lines
4.3 KiB
Python
"""Gate Activity Set API — A1 minimal usability."""
|
||
|
||
from __future__ import annotations
|
||
|
||
from tests.factories import provision_user_in_tenant
|
||
from tests.test_initiatives_actions import _auth, _create_initiative, _login
|
||
|
||
|
||
def test_gate_practice_create_and_list(client):
|
||
user = provision_user_in_tenant(tenant_role="admin")
|
||
token = _login(client, user)
|
||
|
||
created = _create_initiative(
|
||
client,
|
||
token,
|
||
title="A1 Gate Practices",
|
||
archetype_key="initiative.maturity_journey",
|
||
apply_starter_kit=False,
|
||
)
|
||
initiative_id = created.json()["id"]
|
||
|
||
gate = client.post(
|
||
f"/api/initiatives/{initiative_id}/roadmap/items",
|
||
json={
|
||
"title": "Dehnung — Einstieg",
|
||
"item_type": "maturity_stage",
|
||
"status": "active",
|
||
},
|
||
headers=_auth(token),
|
||
)
|
||
assert gate.status_code == 201
|
||
gate_id = gate.json()["id"]
|
||
|
||
empty = client.get(
|
||
f"/api/roadmap-items/{gate_id}/practices",
|
||
headers=_auth(token),
|
||
)
|
||
assert empty.status_code == 200
|
||
assert empty.json() == []
|
||
|
||
created_practice = client.post(
|
||
f"/api/roadmap-items/{gate_id}/practices",
|
||
json={
|
||
"title": "Vorbeuge halten",
|
||
"description": "3×30 Sek.",
|
||
},
|
||
headers=_auth(token),
|
||
)
|
||
assert created_practice.status_code == 201
|
||
body = created_practice.json()
|
||
assert body["roadmap_item_id"] == gate_id
|
||
assert body.get("action_id")
|
||
assert (body.get("schedule") or {}).get("schedule_kind") == "weekdays"
|
||
assert body["schedule"]["weekday_mask"] > 0
|
||
|
||
listed = client.get(
|
||
f"/api/roadmap-items/{gate_id}/practices",
|
||
headers=_auth(token),
|
||
)
|
||
assert listed.status_code == 200
|
||
assert len(listed.json()) == 1
|
||
assert listed.json()[0]["title"] == "Vorbeuge halten"
|
||
assert listed.json()[0].get("action_id")
|
||
|
||
|
||
def test_gate_practice_weekdays_creates_action_bridge(client):
|
||
user = provision_user_in_tenant(tenant_role="admin")
|
||
token = _login(client, user)
|
||
|
||
created = _create_initiative(
|
||
client,
|
||
token,
|
||
title="A1 Weekday Practices",
|
||
archetype_key="initiative.maturity_journey",
|
||
apply_starter_kit=False,
|
||
)
|
||
initiative_id = created.json()["id"]
|
||
|
||
gate = client.post(
|
||
f"/api/initiatives/{initiative_id}/roadmap/items",
|
||
json={
|
||
"title": "Dehnung — Einstieg",
|
||
"item_type": "maturity_stage",
|
||
"status": "active",
|
||
},
|
||
headers=_auth(token),
|
||
)
|
||
assert gate.status_code == 201
|
||
gate_id = gate.json()["id"]
|
||
|
||
created_practice = client.post(
|
||
f"/api/roadmap-items/{gate_id}/practices",
|
||
json={
|
||
"title": "Statisches Stretching",
|
||
"schedule": {
|
||
"schedule_kind": "weekdays",
|
||
"weekday_mask": 1 | 4 | 64,
|
||
},
|
||
},
|
||
headers=_auth(token),
|
||
)
|
||
assert created_practice.status_code == 201, created_practice.text
|
||
body = created_practice.json()
|
||
assert body["action_id"]
|
||
assert body.get("schedule", {}).get("schedule_kind") == "weekdays"
|
||
assert body["schedule"]["weekday_mask"] == 1 | 4 | 64
|
||
|
||
action = client.get(
|
||
f"/api/actions/{body['action_id']}",
|
||
headers=_auth(token),
|
||
)
|
||
assert action.status_code == 200
|
||
assert action.json()["roadmap_item_id"] == gate_id
|
||
assert action.json()["status"] == "open"
|
||
|
||
|
||
def test_join_gate_rejects_practices(client):
|
||
user = provision_user_in_tenant(tenant_role="admin")
|
||
token = _login(client, user)
|
||
|
||
created = _create_initiative(
|
||
client,
|
||
token,
|
||
title="Join no practices",
|
||
archetype_key="initiative.maturity_journey",
|
||
apply_starter_kit=False,
|
||
)
|
||
initiative_id = created.json()["id"]
|
||
|
||
join = client.post(
|
||
f"/api/initiatives/{initiative_id}/roadmap/items",
|
||
json={
|
||
"title": "Konsolidierung",
|
||
"item_type": "join_gate",
|
||
"status": "planned",
|
||
},
|
||
headers=_auth(token),
|
||
)
|
||
assert join.status_code == 201
|
||
join_id = join.json()["id"]
|
||
|
||
rejected = client.post(
|
||
f"/api/roadmap-items/{join_id}/practices",
|
||
json={"title": "Nope", "interval_days": 1},
|
||
headers=_auth(token),
|
||
)
|
||
assert rejected.status_code == 400
|