Skip to content

test: fix broken connection-error abort test from #47#52

Merged
mkonopelski-gd merged 1 commit into
mainfrom
claude/57e956d-test-failures-7bdb62
Jul 23, 2026
Merged

test: fix broken connection-error abort test from #47#52
mkonopelski-gd merged 1 commit into
mainfrom
claude/57e956d-test-failures-7bdb62

Conversation

@mkonopelski-gd

Copy link
Copy Markdown
Contributor

Summary

Commit 57e956d (#47, graceful handling of transient API connection errors) left one unit test broken. This PR fixes that test. No production code is changed — the failure was a test-mocking gap, not a regression in the new error handling.

The failure

make unit-tests → backend:

FAILED test/test_execute_all_phases_connection_error.py::test_connection_error_aborts_without_checkpoint
E   TypeError: 'Mock' object can't be awaited

Raised at app/services/claude_code.py:1206raise_if_cancelled(db_adapter, ...)app/state/cancellation.py:58 await db_adapter.get_generation_session(...).

Root cause

execute_all_phases derives db_adapter = generation_session_service.db_adapter and runs a cooperative cancellation check (raise_if_cancelled) before each phase — code that predates #47 (added in the cancel-generation workflow). The new test in #47 passed a bare Mock() service to assert on its checkpoint methods, but never set db_adapter. So the auto-Mock attribute made raise_if_cancelled await a non-awaitable, blowing up before the connection-error abort the test is meant to verify.

The sibling test (test_connection_error_aborts_on_first_occurrence) passes only because it omits the service entirely (db_adapter=None → documented no-op).

The fix

Set svc.db_adapter = None in the failing test, matching the documented DB-less unit-test path (test/state/test_cancellation.py::test_noop_when_db_adapter_is_none). The test then exercises exactly what it asserts: a connection error aborts the workspace without writing the phase checkpoint.

Test evidence

Suite Result
make unit-tests — backend 2040 passed / 36 skipped (was 2039 passed / 1 failed)
make unit-tests — mcp_server 671 passed
make integration-tests Environment-blocked (host port 18000 held by an unrelated container; pytest never ran) — not a code defect
make skip-mode-e2e-tests Environment-blocked (E2E_WORKSPACE_CONFIG unset / no config file) — prerequisite missing, suite not run

The two E2E/integration suites could not execute in this environment for reasons unrelated to the commit; only the unit suite surfaced a real defect, and it is now green.

🤖 Generated with Claude Code

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.
@mkonopelski-gd
mkonopelski-gd merged commit a5c1312 into main Jul 23, 2026
@mkonopelski-gd
mkonopelski-gd deleted the claude/57e956d-test-failures-7bdb62 branch July 23, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants