test(backend): assert process_audio threads the game-system context into summarise; share same_task_session (#457) #646
Loading…
Reference in a new issue
No description provided.
Delete branch "test/457-process-audio-harness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Test-only. Nothing under
webapp/backend/app/changes.1. One
same_task_sessionfixtureCelery task bodies open their own session with
task_session(). Thedbfixture never really commits (commitis aliased toflush, then rolled back), so without a patch a task can't see any row the test set up. It returns early and the test passes without reaching the code under test. That's how #400 and #401 went wrong.The patch was hand-copied into 14 files:
same_task_sessionfixturestest_reminder_tasks.py/test_previously_on_recap.py_yield_db) intest_availability.pyandtest_summary_recompose.py, which a search for the fixture name missedAll were behaviourally identical: each patches only
app.database.task_sessionwith a bareyield db. They're now one fixture inconftest.py, with a docstring explaining the silent-pass failure it prevents.Refactor mutation check: with the shared fixture made a no-op, 14 tests across 5 converted files went red; they're green again with it restored. The at-risk tests in
test_availability.pyguard this by construction: with no patch, the poller finds no session andcall_count == 1fails.2.
summarisegets the resolved game-system context throughprocess_audiotest_process_audio_system_context.pydrivesprocess_audio.run(...)end to end, with only the provider calls stubbed (the seam fromtest_hallucination_filter.py). It interceptsaudio_service.summariseand asserts on the argument it was actually called with."Homebrew Steampunk System"unchanged.prompt_hint, and not the raw column.Both cases run the real
resolve_system_prompt_contextagainst an in-memoryCampaign(and, for the linked case,GameSystem); neither branch needs a database. Together they tell resolving the context apart from simply passingcampaign.game_systemthrough.Mutation check: passing
Noneat thesummarise(...)call site inreminder_tasks.pyfails both tests (assert None == 'Homebrew Steampunk System',assert None == 'D&D 5th Edition characters are built from…'); restored,git diff webapp/backend/appis empty.3. The gap note is gone
The "summarise() call site" note in
test_system_aware_prompts.pyis removed, and the module docstring now points to the new test.Verification
ruff format --check/ruff checkclean under CI's pinned 0.4.4.Against #457's acceptance criteria
task_session; the hand-copied duplicates are removed.process_audioend to end with external seams stubbed. Theseamfixture intest_failed_windows.pyalready did this; the new module adds a case aimed atsummarise.summarisereceives the resolved context, for linked and free-form campaigns.test_system_aware_prompts.pyis removed.Item 4 (sequencing guards for #421/#425/#431/#432/#397) was optional and isn't in this PR.
Closes #457
🤖 Generated with Claude Code