generated from coulomb/repo-seed
Add lifecycle helper regression tests
This commit is contained in:
68
tests/test_lifecycle.py
Normal file
68
tests/test_lifecycle.py
Normal file
@@ -0,0 +1,68 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from api.services.lifecycle import (
|
||||
has_active_task_status,
|
||||
should_activate_parent_for_active_tasks,
|
||||
should_activate_parent_for_task_start,
|
||||
status_value,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("parent_status", ["proposed", "ready", "backlog"])
|
||||
def test_task_start_activates_planning_parent(parent_status):
|
||||
assert should_activate_parent_for_task_start(
|
||||
previous_task_status="todo",
|
||||
new_task_status="in_progress",
|
||||
parent_workstream_status=parent_status,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("parent_status", ["active", "blocked", "finished", "archived"])
|
||||
def test_task_start_does_not_rewrite_non_planning_parent(parent_status):
|
||||
assert not should_activate_parent_for_task_start(
|
||||
previous_task_status="todo",
|
||||
new_task_status="in_progress",
|
||||
parent_workstream_status=parent_status,
|
||||
)
|
||||
|
||||
|
||||
def test_task_start_requires_todo_to_in_progress_transition():
|
||||
assert not should_activate_parent_for_task_start(
|
||||
previous_task_status="in_progress",
|
||||
new_task_status="in_progress",
|
||||
parent_workstream_status="ready",
|
||||
)
|
||||
assert not should_activate_parent_for_task_start(
|
||||
previous_task_status="todo",
|
||||
new_task_status="done",
|
||||
parent_workstream_status="ready",
|
||||
)
|
||||
|
||||
|
||||
def test_has_active_task_status_ignores_terminal_and_todo_statuses():
|
||||
assert has_active_task_status(["todo", "done", "cancelled"]) is False
|
||||
assert has_active_task_status(["todo", "blocked"]) is True
|
||||
assert has_active_task_status(["in_progress"]) is True
|
||||
|
||||
|
||||
def test_active_task_state_activates_planning_parent_for_renormalization():
|
||||
assert should_activate_parent_for_active_tasks(
|
||||
parent_workstream_status="proposed",
|
||||
task_statuses=["todo", "in_progress"],
|
||||
)
|
||||
|
||||
|
||||
def test_active_task_state_does_not_unblock_blocked_parent():
|
||||
assert not should_activate_parent_for_active_tasks(
|
||||
parent_workstream_status="blocked",
|
||||
task_statuses=["in_progress"],
|
||||
)
|
||||
|
||||
|
||||
def test_status_value_unwraps_enum_like_values():
|
||||
class Status:
|
||||
value = "In_Progress"
|
||||
|
||||
assert status_value(Status()) == "in_progress"
|
||||
Reference in New Issue
Block a user