Expand unit test coverage for JSON I/O, Prompt, and Tavern modules #41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR significantly expands the unit test coverage for the FishE project, adding 12 new test functions across 5 test files. The changes focus on previously untested or under-tested modules, particularly file I/O operations and edge cases.
Changes Made
New Test File
tests/prompt/test_prompt.py- Created comprehensive tests for thePromptclass, which previously had no test coverageEnhanced Test Coverage
JSON Reader/Writer Classes
Added file I/O tests for all three JSON reader/writer classes:
playerJsonReaderWriter.py- Addedtest_writePlayerToFileandtest_readPlayerFromFileto verify serialization/deserializationstatsJsonReaderWriter.py- Addedtest_writeStatsToFileandtest_readStatsFromFileto verify stats persistencetimeServiceJsonReaderWriter.py- Addedtest_writeTimeServiceToFileandtest_readTimeServiceFromFileto verify time tracking persistenceThese tests use temporary files to ensure file I/O operations work correctly and handle data round-trips properly.
Tavern Gambling Logic
Enhanced tavern tests with additional edge case coverage:
test_gamble_loss- Tests the gambling loss scenario and stat trackingtest_changeBet_insufficient_money- Tests error handling when player bets more than they havetest_changeBet_invalid_input- Tests handling of non-numeric inputtest_getDrunk_updates_stats- Verifies stat updates when getting drunkCoverage Improvements
playerJsonReaderWriter.py: 80% → 100% ✅statsJsonReaderWriter.py: 80% → 100% ✅timeServiceJsonReaderWriter.py: 75% → 100% ✅prompt.py: 0% → 100% ✅tavern.py: 65% → 70% (+5%)Testing
All 78 tests pass successfully:
$ python3 -m pytest --cov=src --cov-report=term 78 passed in 0.73s TOTAL coverage: 87%Notes
All new tests follow the existing test patterns in the repository (prepare/call/check structure) and use appropriate mocking to avoid side effects. The tests are focused on validating core functionality and edge cases without modifying any production code.
Original prompt
Fixes #40
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.