From 763ccf29800e488b6494b96592d892f12030d090 Mon Sep 17 00:00:00 2001 From: Mateusz Konopelski Date: Thu, 23 Jul 2026 10:05:00 +0200 Subject: [PATCH] test: fix connection-error abort test mocking the cancellation seam MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_connection_error_aborts_without_checkpoint (added in #47) passed a Mock generation_session_service without configuring db_adapter. Because execute_all_phases derives `db_adapter = generation_session_service.db_adapter` and calls raise_if_cancelled() before each phase, the auto-Mock adapter made raise_if_cancelled await a non-awaitable Mock (get_generation_session), raising TypeError before the connection-error abort under test was ever reached. Set svc.db_adapter = None so raise_if_cancelled hits its documented DB-less no-op path (matching test/state/test_cancellation.py::test_noop_when_db_adapter_is_none), leaving the test to exercise only the checkpoint-abort behavior it asserts. Code under test is unchanged — this was a test-mocking gap at the seam with the pre-existing cancellation check, not a regression in error handling. Backend: 2040 passed / 36 skipped. mcp_server: 671 passed. --- backend/test/test_execute_all_phases_connection_error.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/test/test_execute_all_phases_connection_error.py b/backend/test/test_execute_all_phases_connection_error.py index 3916e52..fd08820 100644 --- a/backend/test/test_execute_all_phases_connection_error.py +++ b/backend/test/test_execute_all_phases_connection_error.py @@ -53,6 +53,10 @@ async def test_connection_error_aborts_without_checkpoint(tmp_path: Path) -> Non svc = Mock() svc.update_workspace_phase = AsyncMock() svc.update_deployment_workspace_phase = AsyncMock() + # No live DB in this unit test: execute_all_phases derives db_adapter from the + # service for the per-phase cancellation check; None makes raise_if_cancelled a + # no-op (its documented DB-less path) so the connection-error abort is reached. + svc.db_adapter = None async def fake_phase_fn(**kwargs): return AgentResult(