test: mock-based integration tests for post-game refractor hook #148
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
ai-working
bug
enhancement
feature
in-queue
performance
security
tech-debt
todo
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-discord#148
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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?
Problem
Post-game hook tests (REF-50+) and tier-up notification tests (REF-60+) require a live game to test end-to-end. No automated tests cover the actual post-game flow: season-stats update → evaluate-game call → notification dispatch → variant render trigger.
The hook at
logic_gameplay.py:4374-4387is wrapped in try/except with a warning log, so failures are silent in production.Proposed Approach
Create mock-based integration tests that simulate the post-game flow:
db_post("season-stats/update-game/...")returning successdb_post("refractor/evaluate-game/...")returning tier-up datanotify_tier_completionis called with correct arguments_trigger_variant_rendersis called for tier-ups withvariant_createdThis can run in CI without a live game and catches regressions in the orchestration logic.
PR #158 opened: #158
Approach: Extracted the inline
try/exceptblock fromcomplete_game()(lines 4374–4387) into_run_post_game_refractor_hook(db_game_id, channel). This makes the hook directly testable without wiring up a full game session.Added 13 tests in
tests/test_post_game_refractor_hook.pycovering: