mantimon-tcg/backend/tests/unit/services
Cal Corum 531d3e1e79 Implement GameService.end_game with history archival (GS-005)
- Add GameEndResult dataclass with winner, loser, final views, duration
- Add _map_end_reason() to map core GameEndReason to DB EndReason
  (raises ValueError for unknown reasons to catch missing enum sync)
- Enhance end_game() to build replay data and return comprehensive result
- Add archive_to_history() to GameStateManager for complete game archival:
  - Creates GameHistory record with replay data
  - Deletes ActiveGame record
  - Clears Redis cache
  - All in single transaction
- Add ArchiveResult dataclass for archive operation metadata
- Add TODO for session_factory DI refactor in GameStateManager
- Update tests: 5 new end_game tests, 6 new archive_to_history tests

Phase 4 progress: 10/18 tasks complete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 20:10:27 -06:00
..
__init__.py Phase 3: Collections + Decks - Services and DI architecture 2026-01-28 11:27:14 -06:00
test_connection_manager.py Validate connection data integrity in ConnectionManager 2026-01-29 19:03:17 -06:00
test_deck_validator.py Fix medium priority issues from code review 2026-01-28 14:32:08 -06:00
test_game_service.py Implement GameService.end_game with history archival (GS-005) 2026-01-29 20:10:27 -06:00
test_game_state_manager.py Implement GameService.end_game with history archival (GS-005) 2026-01-29 20:10:27 -06:00