chore: update generated files to orval v8.3.0 and adjust related interfaces

This commit is contained in:
Abhimanyu Saharan
2026-02-12 18:04:35 +05:30
parent c73103d5c9
commit 2ebdead95b
232 changed files with 9434 additions and 6021 deletions

View File

@@ -0,0 +1,99 @@
from __future__ import annotations
from dataclasses import dataclass
from uuid import UUID, uuid4
import pytest
from fastapi import HTTPException
from app.api import agent as agent_api
from app.core.agent_auth import AgentAuthContext
from app.models.agents import Agent
from app.models.boards import Board
from app.models.task_tags import TaskTag
@dataclass
class _FakeExecResult:
tags: list[TaskTag]
def all(self) -> list[TaskTag]:
return self.tags
@dataclass
class _FakeSession:
tags: list[TaskTag]
async def exec(self, _query: object) -> _FakeExecResult:
return _FakeExecResult(self.tags)
def _board() -> Board:
return Board(
id=uuid4(),
organization_id=uuid4(),
name="Delivery",
slug="delivery",
)
def _agent_ctx(*, board_id: UUID | None) -> AgentAuthContext:
return AgentAuthContext(
actor_type="agent",
agent=Agent(
id=uuid4(),
board_id=board_id,
gateway_id=uuid4(),
name="Lead",
is_board_lead=True,
),
)
@pytest.mark.asyncio
async def test_list_task_tags_returns_task_tag_refs() -> None:
board = _board()
session = _FakeSession(
tags=[
TaskTag(
id=uuid4(),
organization_id=board.organization_id,
name="Backend",
slug="backend",
color="0f172a",
),
TaskTag(
id=uuid4(),
organization_id=board.organization_id,
name="Urgent",
slug="urgent",
color="dc2626",
),
],
)
response = await agent_api.list_task_tags(
board=board,
session=session, # type: ignore[arg-type]
agent_ctx=_agent_ctx(board_id=board.id),
)
assert [tag.slug for tag in response] == ["backend", "urgent"]
assert response[0].name == "Backend"
assert response[1].color == "dc2626"
@pytest.mark.asyncio
async def test_list_task_tags_rejects_cross_board_agent() -> None:
board = _board()
session = _FakeSession(tags=[])
with pytest.raises(HTTPException) as exc:
await agent_api.list_task_tags(
board=board,
session=session, # type: ignore[arg-type]
agent_ctx=_agent_ctx(board_id=uuid4()),
)
assert exc.value.status_code == 403

View File

@@ -0,0 +1,128 @@
# ruff: noqa
from __future__ import annotations
from dataclasses import dataclass, field
from uuid import uuid4
import pytest
from app.models.task_tags import TaskTag
from app.services import task_tags
@dataclass
class _FakeSession:
exec_results: list[object]
executed: list[object] = field(default_factory=list)
added: list[object] = field(default_factory=list)
async def exec(self, query):
self.executed.append(query)
if not self.exec_results:
raise AssertionError("No more exec_results left for session.exec")
return self.exec_results.pop(0)
def add(self, value):
self.added.append(value)
def test_slugify_task_tag_normalizes_text():
assert task_tags.slugify_task_tag("Release / QA") == "release-qa"
assert task_tags.slugify_task_tag(" ### ") == "tag"
@pytest.mark.asyncio
async def test_validate_task_tag_ids_dedupes_and_preserves_order():
org_id = uuid4()
tag_a = uuid4()
tag_b = uuid4()
session = _FakeSession(exec_results=[{tag_a, tag_b}])
result = await task_tags.validate_task_tag_ids(
session,
organization_id=org_id,
tag_ids=[tag_a, tag_b, tag_a],
)
assert result == [tag_a, tag_b]
@pytest.mark.asyncio
async def test_validate_task_tag_ids_rejects_missing_tags():
org_id = uuid4()
tag_a = uuid4()
missing = uuid4()
session = _FakeSession(exec_results=[{tag_a}])
with pytest.raises(task_tags.HTTPException) as exc:
await task_tags.validate_task_tag_ids(
session,
organization_id=org_id,
tag_ids=[tag_a, missing],
)
assert exc.value.status_code == 404
assert exc.value.detail["missing_tag_ids"] == [str(missing)]
@pytest.mark.asyncio
async def test_load_task_tag_state_groups_rows_by_task_id():
task_a = uuid4()
task_b = uuid4()
tag_a = uuid4()
tag_b = uuid4()
session = _FakeSession(
exec_results=[
[
(
task_a,
TaskTag(
id=tag_a,
organization_id=uuid4(),
name="Backend",
slug="backend",
color="0f172a",
),
),
(
task_a,
TaskTag(
id=tag_b,
organization_id=uuid4(),
name="Urgent",
slug="urgent",
color="dc2626",
),
),
(
task_b,
TaskTag(
id=tag_b,
organization_id=uuid4(),
name="Urgent",
slug="urgent",
color="dc2626",
),
),
],
],
)
state = await task_tags.load_task_tag_state(
session,
task_ids=[task_a, task_b],
)
assert state[task_a].tag_ids == [tag_a, tag_b]
assert [tag.name for tag in state[task_a].tags] == ["Backend", "Urgent"]
assert state[task_b].tag_ids == [tag_b]
@pytest.mark.asyncio
async def test_replace_task_tags_replaces_existing_links():
task_id = uuid4()
tag_a = uuid4()
tag_b = uuid4()
session = _FakeSession(exec_results=[None])
await task_tags.replace_task_tags(
session,
task_id=task_id,
tag_ids=[tag_a, tag_b, tag_a],
)
assert len(session.executed) == 1
assert len(session.added) == 2

View File

@@ -67,6 +67,7 @@ def test_task_event_payload_includes_activity_for_comment_event() -> None:
task,
deps_map={},
dep_status={},
tag_state_by_task_id={},
)
assert payload["type"] == "task.comment"
@@ -98,6 +99,7 @@ def test_task_event_payload_includes_activity_for_non_comment_event() -> None:
task,
deps_map={},
dep_status={},
tag_state_by_task_id={},
)
assert payload["type"] == "task.updated"