Repository navigation
test(optimizer): add unit tests for the update-mode helpers - #418
Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Conversation
skillopt/optimizer/update_modes.py decides which payload key the optimizer reads and writes for each update mode (edits, revise suggestions or full-skill candidates), applies the edit budget, and renders the item descriptions shown to the optimizer when it ranks edits. It had no direct tests. Cover mode aliases and the fallback to patch mode for unknown names, payload keys and labels, malformed payload handling, edit-budget truncation including the zero and negative cases, and the per-mode describe_item and short_item_summary output. No runtime code changes.
This branch has not been deployed
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
Adds
tests/test_update_modes.py, direct unit tests forskillopt/optimizer/update_modes.py. These helpers decide which payload key the optimizer reads and writes for each update mode (edits,revise_suggestionsorskill_candidates), apply the edit budget, and render the item descriptions the optimizer sees when it ranks edits. They had no tests of their own, so a regression would only show up as the optimizer silently reading the wrong key or getting the wrong number of edits.No runtime code changes.
What the tests cover
patch,edits,rewrite,suggestions,full_rewriteand the other documented names, case and whitespace insensitive, plus the fallback to patch mode for unknown names.None, a non-dict container, or a non-list payload all read as no items.truncate_payloadwith a budget below, equal to and above the item count, a zero budget, and a negative budget (no limit); it only touches the active mode's key.describe_itemandshort_item_summaryoutput for each mode, including a support count of0and the strippednew_skillpreview.Testing
python -m pytest tests/test_update_modes.py -q: 32 passed.python -m pytest -q: 2319 passed, 12 skipped, 4 xfailed (32 more thanmainataf8f9ef).python -m ruff check tests/test_update_modes.pyandpython -m ruff format --check tests/test_update_modes.py: clean.python -m mkdocs build --strict: passed.To check that the tests catch real regressions, I made each of these changes to
update_modes.pyin turn, ran the tests, and reverted. Every one makes at least one test fail:update_modes.pysuggestionsaliaseditsas the full-rewrite payload key0new_skillpreviewchange_summaryRisk and compatibility
Test-only change plus a CHANGELOG line under Unreleased / Tests. No dependencies added; the tests are pure Python and run without network access.