test: refractor system comprehensive test coverage #117
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
ai-working
bug
enhancement
feature
in-queue
performance
security
tech-debt
todo
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-discord#117
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "test/refractor-comprehensive"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Test plan
Notable findings
build_tier_up_embeduses baretier_up["player_name"]dict access — the minimal stub shape from the post-game hook will KeyError in production when WP-14 wires in the real function🤖 Generated with Claude Code
Implements all gap tests identified by PO agents across three existing test files. No new files created — tests added to existing modules. T1-5 (test_refractor_notifs): Expose WP-14 integration bug — minimal stub dict {player_id, old_tier, new_tier} causes KeyError in build_tier_up_embed because player_name/track_name use bare dict access. Documents the bug contract so WP-14 implementers know what to fix. T1-6 (test_refractor_commands): Divergence tripwire — imports TIER_NAMES from both cogs.refractor and helpers.refractor_notifs and asserts deep equality. Will fail the moment the two copies fall out of sync. T1-7 (test_card_embed_refractor): TIER_BADGES format contract — asserts that wrapping helpers.main badge values in brackets produces cogs.refractor badge values (e.g. "BC" -> "[BC]") for all tiers. T2-7 (test_refractor_notifs): notify_tier_completion with None channel must not raise — the try/except absorbs AttributeError from None.send(). T2-8 (test_refractor_commands): All-T4 apply_close_filter returns empty list. Documents intended behaviour for tier=4 + progress="close" combo. T3-2 (test_refractor_commands): Malformed API response handling — format_refractor_entry must use fallbacks ("Unknown", 0) for missing keys. T3-3 (test_refractor_commands): Progress bar boundary precision — 1/100, 99/100, 0/100, and negative current values. T3-4 (test_refractor_commands): RP formula label — card_type="rp" shows "IP+K" (previously only "sp" was tested). T3-5 (test_refractor_commands): Unknown card_type falls back to raw string as the formula label without crashing. 112 tests pass (23 new, 89 pre-existing). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>AI Code Review
Files Reviewed
tests/test_card_embed_refractor.py(modified — addedTestTierBadgesFormatConsistency)tests/test_refractor_commands.py(modified — addedTestTierNamesDivergenceCheck,TestApplyCloseFilterWithAllT4Cards,TestFormatRefractorEntryMalformedInput,TestRenderProgressBarBoundaryPrecision,TestRPFormulaLabel,TestUnknownCardTypeFallback)tests/test_refractor_notifs.py(modified — addedTestTierUpDictShapeMismatch,TestNotifyTierCompletionNoneChannel)Source files read for verification:
cogs/refractor.py,helpers/refractor_notifs.py,helpers/main.pyFindings
Correctness
All assertions were verified against the actual source implementations.
T1-5 (
TestTierUpDictShapeMismatch):build_tier_up_embeduses baretier_up["player_name"]andtier_up["track_name"](confirmed athelpers/refractor_notifs.pylines 50, 52).test_minimal_stub_shape_raises_key_errorcorrectly documents the realKeyError. The companiontest_full_shape_does_not_raiseusesmake_tier_upwhich supplies all required keys — correct.T1-6 (
TestTierNamesDivergenceCheck): Bothcogs/refractor.pyandhelpers/refractor_notifs.pydefine identicalTIER_NAMESdicts (T0-T4). The tripwire pattern (equality + key set + per-value) is sound. Call-time imports avoid monkeypatch interference as noted.T1-7 (
TestTierBadgesFormatConsistency): Confirmedhelpers/main.pyuses bare strings ({1: "BC", 2: "R", 3: "GR", 4: "SF"}) andcogs/refractor.pyuses bracket strings ({1: "[BC]", 2: "[R]", ...}). The bracket-wrapping relationship is real. The four per-tier spot checks are redundant with the parametric test but low-cost and useful as documentation.T2-7 (
TestNotifyTierCompletionNoneChannel):notify_tier_completionwraps its entire body intry/except Exception, which catches theAttributeErrorfromNone.send(). The test correctly expects no raise.T2-8 (
TestApplyCloseFilterWithAllT4Cards): Thecurrent_tier >= 4 or not next_thresholdguard inapply_close_filterexcludes all T4 cards regardless of formula_value. Both test methods assert correct behavior.T3-2 (
TestFormatRefractorEntryMalformedInput): All four assertions verified.format_refractor_entryuses.get()with fallbacks for all fields. The empty-dict test correctly produces two lines because thenext_thresholddefaults toNonevia.get(), triggering the FULLY EVOLVED branch.T3-3 (
TestRenderProgressBarBoundaryPrecision): The negative value test correctly expects 0 filled segments. One note: the docstring attributes the behavior to themin(..., 1.0)clamp, but it is actuallyround()that truncates the small negative ratio to 0. The test result is correct regardless.T3-4 (
TestRPFormulaLabel):FORMULA_LABELSmaps"rp"to"IP+K". Assertion is correct. Closes the gap where only"sp"was previously tested.T3-5 (
TestUnknownCardTypeFallback):FORMULA_LABELS.get(card_type, card_type)falls back to the raw string. Both"util"and"dh"are absent fromFORMULA_LABELS, so both tests assert correctly.Security
No issues found. Tests only import from internal modules with no new external dependencies or I/O.
Style & Conventions
# -----------pattern throughout all three files.TestFooBarnaming convention.test_refractor_commands.pyare valid cleanup.Suggestions
test_negative_current_does_not_overflow_barsays "themin(..., 1.0)clamp inrender_progress_barshould handle this." This is slightly inaccurate — negative values pass through the clamp (since-0.05 < 1.0) and the zero result comes fromround()truncating the negative. Not a correctness issue, but worth a follow-up docstring fix to avoid misleading anyone who later modifiesrender_progress_bar.TestTierNamesDivergenceCheck.test_tier_names_have_same_keysandtest_tier_names_have_same_valuesare fully subsumed bytest_tier_names_are_identical_across_modules. They are not wrong, and the pattern is consistent with howTestTierBadgesFormatConsistencyhandles the same concern.Verdict: APPROVED
All 23 new test cases correctly assert against the actual source implementations. The WP-14 bug documentation test uses
pytest.raises(KeyError)correctly — intent is clearly stated and the test will fail (become green-then-red) exactly when WP-14 fixes the underlying issue, at which point it should be converted to a positive assertion. Cross-module divergence tripwires target a real duplication risk. No pattern violations, no incorrect assertions found.Automated review by Claude PR Reviewer