Repository navigation
Expand unit tests for milestone/achievement helpers - #222
Merged
Merged
Conversation
Cover arcadeIdForName, the ordering and recording behaviour of getNewlyEarned/getMilestoneStatuses, isEarned on a missing stat, and data-integrity guards on MILESTONES (every stat exists on Stats, names are unique and distinct from the goal, thresholds are positive). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Self-review rubric (Stage B, test-only diff):
Judgment call flagged for the reviewer:
Out-of-diff observation: locally, Summary: a test-only expansion of the achievements helpers. CI is green with 980 tests, and the PR is ready to merge. This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Stage B (unit-test expansion) cycle targeting
src/achievements/achievements.py. Before this PR the module (238 lines) was covered by 4 tests intests/achievements/test_achievements.py.arcadeIdForNamehad no direct test, and the integrity of theMILESTONESdata table was not checked anywhere.15 characterization tests are added. Production code is not changed.
MILESTONES: everystatis a realStatsattribute. This matters becauseisEarnedfalls back to0throughgetattr, so a typo instatwould make a milestone silently impossible to earn. The guards also check that milestone names are unique and do not collide withGOAL_MILESTONE_NAME(these names are whatstats.earnedMilestonespersists), and that every threshold is positive and every description is non-empty.isEarned: a missing stat is not earned.getMilestoneStatuses: the order matchesMILESTONES, earned flags are correct, and nothing is recorded onstats.earnedMilestones.getNewlyEarned: several milestones earned at once come back inMILESTONESorder. Milestones already recorded by a loaded save are skipped. A fresh game returns nothing.arcadeIdForName: maps the goal, maps a milestone that has an arcade id, and returnsNonefor a milestone without an arcade id and for an unknown name.arcadeDeclarations: milestones come first, then the goal, then retirement, with exact goal/retired entries. Title, description and hidden flags come from each milestone. This complements the id-validity checks already intests/achievements/test_arcade.py.No tracking issue: the issue backlog was empty at triage, so this cycle was given to test expansion. Every new test passed against the unchanged code, and no bug was found.
Test plan
python3 -m pytest tests/achievements/test_achievements.py: 19 passed (4 existing + 15 new)tests/test_saveFileManager.py::test_migrate_old_save_files_skips_a_slot_holding_any_file. It is caused by the sandbox's locally installed editable tak 0.1.1 instead of the commit pinned inrequirements.txt, and is unrelated to this test-only diff. CI installs the pinned tak and is the authoritative anchor.Run Unit Testsgreen on the PR headThis PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson