Repository navigation
Description
Summary
Nine tests fail because their mocks/fixtures still describe an older shape of the code they stub. In every case the production code is correct and the test is stale — but each one silently stopped testing what its name claims, so the failures are lost coverage rather than noise.
1. Circuit-breaker fast-fail (3 tests) — tests/test_cb_probe_execution_close.py::TestCircuitBreakerFastFail (test_cb_open_fails_execution_record, …_does_not_call_agent, …_does_not_mark_dispatched):
TypeError: object MagicMock can't be used in 'await' expression
at src/backend/services/task_execution_service.py:856 in _write_terminal_and_gate
The mock db predates the async call #1804 added to the terminal path (the close_execution_activity / terminal-event seam), so a plain MagicMock is returned where the code awaits.
2. Audit hash chain (2 tests) — tests/test_audit_log_unit.py::test_hash_chain_produces_hashes (assert None is not None) and ::test_verify_chain_valid_with_details (assert 0 == 2). The audit_service fixture builds a fake database.db wiring only create_audit_entry, get_audit_entries, get_audit_entries_range. #2015 moved the chain from an in-process flag to durable system_settings, so it now needs set_setting / get_setting / create_audit_entry_chained. The MagicMock swallows the write, the (correct, deliberate) fail-closed reader answers "off", and nothing is ever hashed.
3. GitHub PAT propagation (4 tests) — tests/test_github_pat_propagation_unit.py, all four failing with cannot import name 'AgentGitConfig' from 'database' (unknown location) surfacing as empty updated lists.
4. Skills-library sync (1 test) — tests/test_skills.py::TestSkillsLibrarySync::test_sync_requires_url_configured expects 400 for "no library URL configured", but ent#237 replaced the single skills_library_url setting with the multi-source skill_sources table. A migrated source now exists, sync succeeds, and the endpoint correctly returns 200. The test asserts a contract that no longer exists.
5. PostgreSQL tier isolation (1 error) — test_migration_is_conditional_inside_the_container fails at setup with UniqueViolation: duplicate key value violates unique constraint "users_pkey", Key (id)=(1). The tier runs many tests against one disposable database and this fixture inserts a fixed-id user a prior test already seeded.
Context
Found by a full-suite run on dev (691e7dc9): unit 8 failed / api 21 failed + 14 errors / postgres 15 failed + 2 errors. This issue covers the stale-mock cluster; the assert_*/MagicMock collision and the calendar-expiring tests are filed separately.
The pattern worth naming: each of these is a test that keeps passing an outdated contract until the stubbed seam changes shape. #1804 and #2015 both moved a seam and left the mock behind, so the tests went red only when someone ran the full suite.
Acceptance Criteria
-
TestCircuitBreakerFastFail(3 tests) pass — the db mock provides the awaitable(s)_write_terminal_and_gatenow uses -
test_hash_chain_produces_hashesandtest_verify_chain_valid_with_detailspass against the bug(audit): enabling the hash chain does not survive a backend restart — the integrity control silently turns itself off #2015 persisted-setting design (fixture wiresset_setting/get_setting/create_audit_entry_chainedto the temp DB) - The 4
test_github_pat_propagation_unit.pytests pass — thedatabasestub exposesAgentGitConfig -
test_sync_requires_url_configuredis rewritten for the ent#237 multi-source model, or deleted with a note saying which test now covers "no sources configured" - The PostgreSQL tier no longer fails on
users_pkey— the fixture does not assume an unseeded database - Each fix asserts the current contract, not a re-mocked version of the old one
Technical Notes
- The audit fixture is the most delicate: bug(audit): enabling the hash chain does not survive a backend restart — the integrity control silently turns itself off #2015's fail-closed read is deliberate (
hash_chain_enabledanswers "off" on a settings-read failure because a settings error is not evidence an integrity record exists). The fixture must make settings genuinely readable rather than force the flag on. - Reproduce:
cd tests && source .venv/bin/activate && source setup-env.sh && python -m pytest test_cb_probe_execution_close.py test_audit_log_unit.py test_github_pat_propagation_unit.py -q - PostgreSQL tier:
tests/run-full.sh --tier postgres
Activity
fix(tests): re-point five stale mocks at the seams they claim to stub (…
fix(workspace): make the `/` typeahead able to find every skill the a…