Changes:
- Created tests/integration/conftest.py with shared fixtures
- Added README.md documenting asyncpg connection pool issue
- Fixed uuid4 import in test_roll_persistence.py
Issue Analysis:
- Integration tests work individually but fail when run together (12+ tests)
- AsyncPG error: "cannot perform operation: another operation is in progress"
- Root cause: pytest-asyncio + asyncpg connection reuse across rapid fixtures
- Tests #1-4 pass, then connection pool enters bad state
Test Status:
✅ 87/88 unit tests pass (1 pre-existing timing issue)
✅ Integration tests PASS individually
⚠️ Integration tests FAIL when run together (fixture issue, not code bug)
Workarounds:
- Run test classes separately
- Run individual tests
- Use pytest-xdist for isolation
The tests themselves are well-designed and use production code paths.
This is purely a test infrastructure limitation to be resolved post-MVP.
Core dice and roll persistence logic is proven correct by unit tests.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Core Implementation:
- Created roll_types.py with AbRoll, JumpRoll, FieldingRoll, D20Roll dataclasses
- Implemented DiceSystem singleton with cryptographically secure random generation
- Added Roll model to db_models.py with JSONB storage for roll history
- Implemented save_rolls_batch() and get_rolls_for_game() in database operations
Testing:
- 27 unit tests for roll type dataclasses (100% passing)
- 35 unit tests for dice system (34/35 passing, 1 timing issue)
- 16 integration tests for database persistence (uses production DiceSystem)
Features:
- Unique roll IDs using secrets.token_hex()
- League-specific logic (SBA d100 rare plays, PD error-based rare plays)
- Automatic derived value calculation (d6_two_total, jump_total, error_total)
- Full audit trail with context metadata
- Support for batch saving rolls per inning
Technical Details:
- Fixed dataclass inheritance with kw_only=True for Python 3.13
- Roll data stored as JSONB for flexible querying
- Indexed on game_id, roll_type, league_id, team_id for efficient retrieval
- Supports filtering by roll type, team, and timestamp ordering
Note: Integration tests have async connection pool issue when run together
(tests work individually, fixture cleanup needed in follow-up branch)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>