Files
roboco/tests/unit/api/test_schemas_v1_flow.py
T

51 lines
1.6 KiB
Python
Raw Normal View History

2026-06-03 06:35:03 +02:00
"""Schema-level tests for v1 flow request bodies."""
from __future__ import annotations
from uuid import uuid4
import pytest
from pydantic import ValidationError
2026-06-03 06:35:03 +02:00
from roboco.api.schemas.v1.flow import DelegateRequest
def test_delegate_request_requires_task_type() -> None:
"""task_type must be supplied explicitly — no magic default.
Background: the 2026-05-08 smoke-test trace showed main-pm calling
delegate without task_type, the schema defaulted to 'code', the
cell PM downstream couldn't plan a code-typed parent (pre-fix), and
the run deadlocked. Make the field required so misuse fails at the
HTTP boundary with a clear 422.
"""
with pytest.raises(ValidationError) as exc:
DelegateRequest.model_validate(
{
"parent_task_id": uuid4(),
"title": "t",
"description": "add the new endpoint plus tests",
"assigned_to": "be-dev-1",
"team": "backend",
"nature": "technical",
"estimated_complexity": "medium",
"acceptance_criteria": ["returns 200"],
# task_type intentionally omitted
}
)
assert "task_type" in str(exc.value)
def test_delegate_request_accepts_explicit_task_type() -> None:
req = DelegateRequest(
parent_task_id=uuid4(),
title="t",
2026-05-11 02:15:47 +02:00
description="add the new endpoint plus tests",
assigned_to="be-dev-1",
team="backend",
task_type="code",
2026-05-11 02:15:47 +02:00
nature="technical",
estimated_complexity="medium",
acceptance_criteria=["returns 200"],
)
assert req.task_type == "code"