fix(tests): satisfy mypy on the queue-item push tests

The #568 tests unpacked AsyncMock.await_args without narrowing its
Optional type and passed a SimpleNamespace where _format_task_detail
is annotated TaskTable. Narrow with the repo-standard 'assert
await_args is not None' and cast the fake task at the call sites.
This commit is contained in:
Renn F
2026-07-18 16:35:28 +02:00
parent ec6558e168
commit 99224e65cd
4 changed files with 10 additions and 4 deletions
@@ -238,6 +238,7 @@ async def test_proposes_sends_telegram_push(
task = await engine.run_cycle()
assert task is not None
notify.assert_awaited_once()
assert notify.await_args is not None
_args, kwargs = notify.await_args
assert kwargs["kind"] == "release"
assert kwargs["id8"] == str(task.id)[:8]
@@ -7,7 +7,7 @@ from __future__ import annotations
import time
from types import SimpleNamespace
from typing import Any, cast
from typing import TYPE_CHECKING, Any, cast
from unittest.mock import AsyncMock, MagicMock
from uuid import UUID, uuid4
@@ -19,6 +19,9 @@ from roboco.services.telegram_credentials import TelegramCredentialsData
from roboco.services.video_post_service import VideoPostExecuteResult
from roboco.services.x_post_service import XPostExecuteResult
if TYPE_CHECKING:
from roboco.db.tables import TaskTable
CEO_UUID = ti._CEO_UUID
@@ -857,7 +860,7 @@ def test_format_task_detail_escapes_html_in_title() -> None:
engine = _engine()
task = _fake_task(title="<b>bold&joke</b>")
rendered = engine._format_task_detail(task)
rendered = engine._format_task_detail(cast("TaskTable", task))
assert "&lt;b&gt;bold&amp;joke&lt;/b&gt;" in rendered
assert "<b>bold&joke</b>" not in rendered
@@ -868,7 +871,7 @@ def test_format_task_detail_pr_url_is_a_named_link() -> None:
task = _fake_task()
task.pr_url = "https://github.com/example/repo/pull/1"
rendered = engine._format_task_detail(task)
rendered = engine._format_task_detail(cast("TaskTable", task))
assert '<a href="https://github.com/example/repo/pull/1">View PR</a>' in rendered
@@ -882,7 +885,7 @@ def test_format_task_detail_pr_url_quote_cannot_break_out_of_href() -> None:
task = _fake_task()
task.pr_url = 'https://evil.example/x" onmouseover="alert(1)'
rendered = engine._format_task_detail(task)
rendered = engine._format_task_detail(cast("TaskTable", task))
assert (
'<a href="https://evil.example/x&quot; onmouseover=&quot;alert(1)">'
+1
View File
@@ -485,6 +485,7 @@ async def test_originate_video_post_sends_telegram_push(
)
notify.assert_awaited_once()
assert notify.await_args is not None
_args, kwargs = notify.await_args
assert kwargs["kind"] == "video"
assert kwargs["id8"] == str(draft_task.id)[:8]
+1
View File
@@ -274,6 +274,7 @@ async def test_originate_post_sends_telegram_push(
)
assert task is not None
notify.assert_awaited_once()
assert notify.await_args is not None
_args, kwargs = notify.await_args
assert kwargs["kind"] == "xpost"
assert kwargs["id8"] == str(task.id)[:8]