All checks were successful
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 1m39s
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 18s
Test Suite / playwright-smoke (push) Successful in 12s
Schema 013; Projekte/Arbeitspakete/Aufgaben pflegbar; Tab Zielzustände vs Ausführung. Co-authored-by: Cursor <cursoragent@cursor.com>
76 lines
2.2 KiB
Python
76 lines
2.2 KiB
Python
"""AP1.5 — Project, Task, Action.project_id."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from tests.factories import provision_user_in_tenant
|
|
from tests.test_initiatives_actions import (
|
|
_auth,
|
|
_create_initiative,
|
|
_login,
|
|
)
|
|
|
|
|
|
def test_project_and_action_hierarchy(client):
|
|
user = provision_user_in_tenant(tenant_role="member")
|
|
token = _login(client, user)
|
|
initiative_id = _create_initiative(client, token).json()["id"]
|
|
|
|
project = client.post(
|
|
f"/api/initiatives/{initiative_id}/projects",
|
|
json={"title": "Karate Grundlagen", "description": "8 Fähigkeiten"},
|
|
headers=_auth(token),
|
|
)
|
|
assert project.status_code == 201
|
|
project_id = project.json()["id"]
|
|
|
|
action = client.post(
|
|
f"/api/initiatives/{initiative_id}/actions",
|
|
json={"title": "Kata Heian Shodan", "project_id": project_id},
|
|
headers=_auth(token),
|
|
)
|
|
assert action.status_code == 201
|
|
assert action.json()["project_id"] == project_id
|
|
|
|
task = client.post(
|
|
f"/api/actions/{action.json()['id']}/tasks",
|
|
json={"title": "Standfußarbeit üben"},
|
|
headers=_auth(token),
|
|
)
|
|
assert task.status_code == 201
|
|
assert task.json()["status"] == "open"
|
|
|
|
listed = client.get(
|
|
f"/api/actions/{action.json()['id']}/tasks",
|
|
headers=_auth(token),
|
|
)
|
|
assert listed.status_code == 200
|
|
assert len(listed.json()) == 1
|
|
|
|
projects = client.get(
|
|
f"/api/initiatives/{initiative_id}/projects",
|
|
headers=_auth(token),
|
|
)
|
|
assert projects.status_code == 200
|
|
assert len(projects.json()) == 1
|
|
|
|
|
|
def test_initiative_without_projects_still_works(client):
|
|
user = provision_user_in_tenant(tenant_role="member")
|
|
token = _login(client, user)
|
|
initiative_id = _create_initiative(client, token).json()["id"]
|
|
|
|
action = client.post(
|
|
f"/api/initiatives/{initiative_id}/actions",
|
|
json={"title": "Freistehende Aufgabe"},
|
|
headers=_auth(token),
|
|
)
|
|
assert action.status_code == 201
|
|
assert action.json().get("project_id") is None
|
|
|
|
projects = client.get(
|
|
f"/api/initiatives/{initiative_id}/projects",
|
|
headers=_auth(token),
|
|
)
|
|
assert projects.status_code == 200
|
|
assert projects.json() == []
|