Kairo-Jinkendo/backend/tests/test_a1_gate_practices.py
Lars 87ecee5301
All checks were successful
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 4m54s
Test Suite / lint-backend (push) Successful in 2s
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
feat(A1): Activity Set am Gate-Detail — Übungen an Zielzustand binden
Gate-Detail: Übungen anlegen mit Rhythmus, Gate aktivieren, Link zu Today. API: /roadmap-items/{id}/practices und roadmap_item_id auf Recurring-Create. Damit ist A1 ohne Starter-Kit manuell durchspielbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-03 19:36:50 +02:00

95 lines
2.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""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.",
"interval_days": 1,
},
headers=_auth(token),
)
assert created_practice.status_code == 201
body = created_practice.json()
assert body["roadmap_item_id"] == gate_id
assert body["interval_days"] == 1
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"
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