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, and implements a GitHub Actions CI workflow to automatically verify tests pass on every push and pull request. 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

CI/CD Integration

  • .github/workflows/test.yml - Added GitHub Actions workflow that automatically runs all unit tests on push and pull requests to main and develop branches
  • README.md - Added status badge to display current test status
  • The workflow includes coverage reporting and optional Codecov integration

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%

The CI workflow is configured to run these tests automatically on every push and pull request, ensuring continuous verification of code quality.

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
@dmccoystephenson
Copy link
Member

@copilot add CI checks to verify unit tests pass

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 1, 2026

@copilot add CI checks to verify unit tests pass

Added GitHub Actions workflow to run unit tests automatically on push and pull requests. The workflow runs all 78 tests with coverage reporting and includes a status badge in the README. Commit: ff272e1

Copilot AI changed the title Expand unit test coverage for JSON I/O, Prompt, and Tavern modules Expand unit test coverage and add CI workflow for automated testing Feb 1, 2026
@dmccoystephenson dmccoystephenson marked this pull request as ready for review February 1, 2026 13:12
@dmccoystephenson dmccoystephenson merged commit 6da77f1 into main Feb 1, 2026
1 check passed
@dmccoystephenson dmccoystephenson deleted the copilot/expand-unit-tests branch February 1, 2026 13:13
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