Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 13, 2025

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 the Prompt class, which previously had no test coverage

Enhanced Test Coverage

JSON Reader/Writer Classes

Added file I/O tests for all three JSON reader/writer classes:

  • playerJsonReaderWriter.py - Added test_writePlayerToFile and test_readPlayerFromFile to verify serialization/deserialization
  • statsJsonReaderWriter.py - Added test_writeStatsToFile and test_readStatsFromFile to verify stats persistence
  • timeServiceJsonReaderWriter.py - Added test_writeTimeServiceToFile and test_readTimeServiceFromFile to verify time tracking persistence

These 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 tracking
  • test_changeBet_insufficient_money - Tests error handling when player bets more than they have
  • test_changeBet_invalid_input - Tests handling of non-numeric input
  • test_getDrunk_updates_stats - Verifies stat updates when getting drunk

Coverage Improvements

  • Overall project coverage: 84% → 87% (+3%)
  • 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

This section details on the original issue you should resolve

<issue_title>Expand unit tests</issue_title>
<issue_description>Create or expand unit tests</issue_description>

Comments on the Issue (you are @copilot in this section)

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.

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copilot AI changed the title [WIP] Expand unit tests for existing code Expand unit test coverage for JSON I/O, Prompt, and Tavern modules Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand unit tests

2 participants