mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
[F061] drop type:ignore from audit-emit tests
Convention: no type:ignore/noqa. The F061 in-session audit-emit tests used '# type: ignore[assignment]' to assign a MagicMock to AsyncSession.add, and the F060 test assigned to .flush the same way. Rewritten to hold a local 'session: MagicMock' variable (mypy sees its auto-children as MagicMock, so .add.side_effect / .flush assign cleanly with no suppression). Verified via 'mypy tests/' that both files are now type-clean (the F060/F061 commits had skipped tests/ in mypy, masking two method-assign errors).
This commit is contained in:
@@ -533,9 +533,11 @@ async def test_apply_escalation_emits_blocked_audit_event() -> None:
|
||||
The audit row is written into the caller's session (F061/F073/F075: it
|
||||
commits atomically with the transition, not fire-and-forget on a separate
|
||||
connection), so we assert on the ``AuditLogTable`` added to the session."""
|
||||
svc = _service()
|
||||
session = MagicMock()
|
||||
session.flush = AsyncMock()
|
||||
added: list[object] = []
|
||||
svc.session.add = MagicMock(side_effect=added.append) # type: ignore[assignment]
|
||||
session.add.side_effect = added.append
|
||||
svc = TaskService(session)
|
||||
task = MagicMock(
|
||||
id=uuid4(),
|
||||
parent_task_id=uuid4(),
|
||||
@@ -573,9 +575,11 @@ async def test_unblock_with_restore_emits_audit_event() -> None:
|
||||
The audit row is written into the caller's session (F061/F073/F075: atomic
|
||||
with the transition, not fire-and-forget), so we assert on the
|
||||
``AuditLogTable`` added to the session."""
|
||||
svc = _service()
|
||||
session = MagicMock()
|
||||
session.flush = AsyncMock()
|
||||
added: list[object] = []
|
||||
svc.session.add = MagicMock(side_effect=added.append) # type: ignore[assignment]
|
||||
session.add.side_effect = added.append
|
||||
svc = TaskService(session)
|
||||
task = MagicMock(
|
||||
id=uuid4(),
|
||||
status=TaskStatus.BLOCKED,
|
||||
|
||||
@@ -1076,8 +1076,9 @@ async def test_finalize_claim_rollback_emits_reversal_audit() -> None:
|
||||
audit trail diverges from real state and corrupts every downstream metric
|
||||
reconstructed from `task.<status>` events (cycle time, bottlenecks).
|
||||
"""
|
||||
svc = TaskService(MagicMock())
|
||||
svc.session.flush = AsyncMock()
|
||||
session = MagicMock()
|
||||
session.flush = AsyncMock()
|
||||
svc = TaskService(session)
|
||||
|
||||
task = _build_task(
|
||||
status=TaskStatus.PENDING,
|
||||
@@ -1134,9 +1135,10 @@ async def test_emit_status_transition_audit_writes_in_session_atomically() -> No
|
||||
``session.add``-ed (same txn) with the metric-reconstruction details, and
|
||||
NO fire-and-forget background task is spawned.
|
||||
"""
|
||||
svc = TaskService(MagicMock())
|
||||
session = MagicMock()
|
||||
added: list[object] = []
|
||||
svc.session.add = MagicMock(side_effect=added.append) # type: ignore[assignment]
|
||||
session.add.side_effect = added.append
|
||||
svc = TaskService(session)
|
||||
prior_bg = set(svc._background_tasks)
|
||||
|
||||
task = MagicMock(id=uuid4(), claimed_by=uuid4(), team=Team.BACKEND)
|
||||
|
||||
Reference in New Issue
Block a user