paper-dynasty-database/tests
Cal Corum c935c50a96 feat: add ProcessedGame ledger for full idempotency in update_season_stats() (#105)
Closes #105

Replace the last_game FK guard in update_season_stats() with an atomic
INSERT into a new processed_game ledger table. The old guard only blocked
same-game immediate replay; it was silently bypassed if game G+1 was
processed first (last_game already overwritten). The ledger is keyed on
game_id so any re-delivery — including out-of-order — is caught reliably.

Changes:
- app/db_engine.py: add ProcessedGame model (game FK PK + processed_at)
- app/services/season_stats.py: replace last_game check with
  ProcessedGame.get_or_create(); import ProcessedGame; update docstrings
- migrations/2026-03-18_add_processed_game.sql: CREATE TABLE IF NOT EXISTS
  processed_game with FK to stratgame ON DELETE CASCADE
- tests/conftest.py: add ProcessedGame to imports and _TEST_MODELS list
- tests/test_season_stats_update.py: add test_out_of_order_replay_prevented;
  update test_double_count_prevention docstring

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 01:05:31 -05:00
..
__init__.py feat: evolution track seed data and tests (WP-03) (#68) 2026-03-12 17:35:12 -05:00
conftest.py feat: add ProcessedGame ledger for full idempotency in update_season_stats() (#105) 2026-03-18 01:05:31 -05:00
test_evolution_models.py test: add Phase 1a test suite (25 tests) 2026-03-17 19:33:49 -05:00
test_evolution_seed.py test: add Phase 1a test suite (25 tests) 2026-03-17 19:33:49 -05:00
test_evolution_track_api.py feat: Track Catalog API endpoints (WP-06) (#71) 2026-03-12 20:40:38 -05:00
test_formula_engine.py refactor: split PlayerSeasonStats into BattingSeasonStats and PitchingSeasonStats 2026-03-17 09:43:22 -05:00
test_season_stats_model.py refactor: deduplicate pitcher formula and test constants 2026-03-17 09:49:33 -05:00
test_season_stats_update.py feat: add ProcessedGame ledger for full idempotency in update_season_stats() (#105) 2026-03-18 01:05:31 -05:00