Skip to content

Add coverage for Bank deposit/withdraw invalid-amount retry - #132

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/bank-invalid-amount-tests
Jul 30, 2026
Merged

Add coverage for Bank deposit/withdraw invalid-amount retry#132
dmccoystephenson merged 1 commit into
mainfrom
feature/bank-invalid-amount-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • Full triage found no open issues/PRs and no documentation drift (README, PLANNING.md, and all three schemas/*.json match their models). No backlog work was skipped/deferred this cycle since the backlog was empty.
  • This cycle is a Stage B unit-test-expansion cycle: src/location/bank.py was the only source file with a coverage gap that represents a real, player-reachable behavior — Bank.deposit()/Bank.withdraw() each loop back and re-prompt when promptForNumber returns None (i.e. the player typed something non-numeric), but neither retry branch had a test.
  • Added test_deposit_invalid_input_retries_then_succeeds and test_withdraw_invalid_input_retries_then_succeeds, mirroring the sibling test structure already in tests/location/test_bank.py, using side_effect=[None, 10.0] to exercise the retry-then-succeed path deterministically.
  • src/location/bank.py is now at 100% line coverage (was 96%, missing exactly these two branches).

Test plan

  • python3 -m compileall -q src
  • Full suite (headless SDL): 404 passed, 0 failed
  • tests/location/test_bank.py alone: 25 passed
  • Coverage check confirms src/location/bank.py at 100%, no other file regressed

Closes: none — no tracking issue existed; this is a proactive Stage B test-expansion cycle per the dev-loop's tiebreaker (documentation/coverage work preferred when the issue backlog is empty).

promptForNumber returns None whenever the player enters non-numeric
text (see baseUserInterface.promptForNumber), and both deposit() and
withdraw() loop back to re-prompt in that case, but neither branch had
a test - bank.py sat at 96% coverage with exactly these two lines
missing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric:

  • Scope: PASS — only tests/location/test_bank.py touched; both new tests target exactly the coverage gap (deposit/withdraw's promptForNumber is None retry branch) called out in the PR description.
  • Tests-new: PASS — test_deposit_invalid_input_retries_then_succeeds and test_withdraw_invalid_input_retries_then_succeeds each exercise the retry-then-succeed path via side_effect=[None, 10.0] and assert call_count == 2 plus the final balances.
  • Tests-fix: N/A — this is a Stage B test-expansion cycle, not a bug fix; no production code changed.
  • Sibling structure: PASS — new tests reuse createBank(), the same MagicMock-ing of lotsOfSpace/divider, and the # prepare / # call / # check comment structure used by every neighboring test in the file.
  • Sibling renames: N/A — no renames in this PR.
  • Docs: PASS — no behavior changed (test-only PR), so README/PLANNING.md/schemas are unaffected; verified none needed updating.
  • Issue resolution: N/A — no tracking issue existed (noted in the PR body); this was proactive coverage work found during triage.
  • CI: PASS — test check green on the PR head (https://github.com/Stephenson-Software/FishE/actions/runs/30521784758).

Repo-specific:

  • Schema-sync: N/A — no persisted fields touched.
  • Money-format: N/A — no display strings touched.
  • Deterministic-tests: PASS — side_effect=[None, 10.0] is a fixed sequence, no unseeded random involved.
  • Headless-pygame: N/A — Bank/console-agnostic UI mock, no pygame surface touched.
  • camelCase: PASS — new test function names (test_deposit_invalid_input_retries_then_succeeds, test_withdraw_invalid_input_retries_then_succeeds) follow the file's existing test_<behavior> snake_case pytest convention.

Coverage confirms src/location/bank.py moved from 96% (missing the two continue branches) to 100% with this PR, and the full suite (404 tests, headless SDL) still passes.

@dmccoystephenson
dmccoystephenson merged commit 448f9bd into main Jul 30, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the feature/bank-invalid-amount-tests branch July 30, 2026 07:07
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.

1 participant