2026-06-03 06:35:03 +02:00
|
|
|
"""Schema-level tests for v1 flow request bodies."""
|
2026-05-08 07:45:18 +02:00
|
|
|
|
|
|
|
|
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
|
2026-05-08 07:45:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
2026-06-14 13:43:46 +02:00
|
|
|
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
|
|
|
|
|
}
|
2026-05-08 07:45:18 +02:00
|
|
|
)
|
|
|
|
|
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",
|
2026-05-08 07:45:18 +02:00
|
|
|
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"],
|
2026-05-08 07:45:18 +02:00
|
|
|
)
|
|
|
|
|
assert req.task_type == "code"
|