strat-gameplay-webapp/backend/tests/unit/core
Cal Corum e6bd66ee39 CLAUDE: Fix game recovery for new GameState structure
Fixed state_manager._rebuild_state_from_data to provide required
current_batter field when recovering games from database. The GameState
model now requires current_batter as a LineupPlayerState object, but
recovery was not populating this field, causing validation errors.

Changes:
- state_manager.py: Create placeholder current_batter during recovery
  - Build LineupPlayerState from first active batter (batting_order=1)
  - Fallback to first available lineup if no #1 batter found
  - Raise error if no lineups exist (invalid game state)
  - _prepare_next_play() will correct the batter after recovery
  - Moved get_lineup_player helper to top of method (removed duplicate)

- tests/unit/core/test_state_manager.py: Update test to use new structure
  - test_update_state_nonexistent_raises_error: Create LineupPlayerState
    instead of using old current_batter_lineup_id field

All 26 state_manager unit tests passing. Game recovery now works
correctly in terminal client - fixes "current_batter Field required"
validation error when running status command on recovered games.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 15:26:00 -06:00
..
__init__.py CLAUDE: Complete Week 4 - State Management & Persistence 2025-10-22 12:01:03 -05:00
test_dice.py CLAUDE: Complete Week 6 - granular PlayOutcome integration and metadata support 2025-10-29 20:29:06 -05:00
test_flyball_advancement.py CLAUDE: Integrate flyball advancement with RunnerAdvancement system 2025-10-31 17:04:23 -05:00
test_play_resolver.py CLAUDE: Update tests to match Phase 2 model changes 2025-10-31 16:11:39 -05:00
test_roll_types.py CLAUDE: Complete Week 6 - granular PlayOutcome integration and metadata support 2025-10-29 20:29:06 -05:00
test_runner_advancement.py CLAUDE: Integrate X-Check advancement with full GameState support 2025-11-03 00:21:52 -06:00
test_state_manager.py CLAUDE: Fix game recovery for new GameState structure 2025-11-04 15:26:00 -06:00
test_validators.py CLAUDE: Update tests to match Phase 2 model changes 2025-10-31 16:11:39 -05:00
test_x_check_advancement_tables.py CLAUDE: Integrate X-Check advancement with full GameState support 2025-11-03 00:21:52 -06:00