fix(testing): add MockCacheManager.get_cached_data_with_strategy/save_cache - #409
Conversation
…_cache ledmatrix-leaderboard's data_fetcher.py calls these two real-CacheManager methods (src/cache_manager.py:313,817), but MockCacheManager had neither -- update() always hit an AttributeError, caught by a broad except and logged, so the harness rendered an empty-but-green leaderboard on every test run without ever exercising real standings data. Both mocks delegate to the existing get()/set() -- a mock doesn't need the real strategy's per-data-type max_age/market-hours timing, plugins under test just need the methods to exist and round-trip whatever was cached.
|
Warning Review limit reached
Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesMock cache strategy support
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/plugin_system/testing/mocks.py`:
- Line 74: Update the mock’s reset() method to clear
get_cached_data_with_strategy_calls alongside the other call trackers
initialized in __init__, ensuring reused mocks do not retain stale strategy-call
records.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c32e73a0-c951-4488-be4b-a0de23678f20
📒 Files selected for processing (2)
src/plugin_system/testing/mocks.pytest/test_testing_mocks.py
…anager.reset() reset() cleared get_calls/set_calls/delete_calls but not the newer get_cached_data_with_strategy_calls tracker, so a reused mock (e.g. across test cases sharing a fixture) retained stale strategy-call records after reset(). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KEZK1P1Q1fu5pcuVrkrCFZ
Summary
ledmatrix-leaderboard'sdata_fetcher.pycallscache_manager.get_cached_data_with_strategy()andcache_manager.save_cache()— both real methods onsrc/cache_manager.py(lines 817 and 313) — butMockCacheManagerimplemented neither.AttributeErrorinsideupdate(), caught by the plugin's own broadexcept Exception, logged, and silently produced an empty-but-PASSing leaderboard — never actually exercising real standings data under test.MockCacheManager, delegating to the mock's existingget()/set()(a mock doesn't need the real strategy's per-data-type max_age/market-hours timing logic — plugins under test just need the methods to exist and round-trip cached values).Test plan
test/test_testing_mocks.py— 5 unit tests for both new methods.pytest test/plugins/test_plugin_matrix.py(deselecting the independently rate-limitedf1-scoreboard) — 23 passed, no regressions.check_plugin.py --plugin ledmatrix-leaderboard --sizes 192x48no longer logs anyAttributeError/cache errors.Summary by CodeRabbit
New Features
Tests