Skip to content

fix(testing): add MockCacheManager.get_cached_data_with_strategy/save_cache - #409

Merged
ChuckBuilds merged 2 commits into
mainfrom
fix/mock-cache-manager-strategy-method
Jul 14, 2026
Merged

fix(testing): add MockCacheManager.get_cached_data_with_strategy/save_cache#409
ChuckBuilds merged 2 commits into
mainfrom
fix/mock-cache-manager-strategy-method

Conversation

@ChuckBuilds

@ChuckBuilds ChuckBuilds commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • ledmatrix-leaderboard's data_fetcher.py calls cache_manager.get_cached_data_with_strategy() and cache_manager.save_cache() — both real methods on src/cache_manager.py (lines 817 and 313) — but MockCacheManager implemented neither.
  • Every harness/CI render of this plugin hit AttributeError inside update(), caught by the plugin's own broad except Exception, logged, and silently produced an empty-but-PASSing leaderboard — never actually exercising real standings data under test.
  • Added both methods to MockCacheManager, delegating to the mock's existing get()/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

  • New test/test_testing_mocks.py — 5 unit tests for both new methods.
  • pytest test/plugins/test_plugin_matrix.py (deselecting the independently rate-limited f1-scoreboard) — 23 passed, no regressions.
  • Manually confirmed check_plugin.py --plugin ledmatrix-leaderboard --sizes 192x48 no longer logs any AttributeError/cache errors.

Summary by CodeRabbit

  • New Features

    • Expanded cache behavior support for plugin testing, including strategy-based lookups and cache-saving operations.
    • Added call tracking for strategy-based cache requests.
  • Tests

    • Added coverage for cached values, missing keys, default data types, call tracking, and saved-cache retrieval.

…_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.
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ChuckBuilds, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8b8304fc-cc37-47a1-9f9b-385c50fc4649

📥 Commits

Reviewing files that changed from the base of the PR and between ee5df2a and 131a913.

📒 Files selected for processing (2)
  • src/plugin_system/testing/mocks.py
  • test/test_testing_mocks.py
📝 Walkthrough

Walkthrough

MockCacheManager now supports strategy-based cache retrieval and saving, records strategy lookup calls, and includes tests for cached values, missing keys, default data types, tracking, and interoperability.

Changes

Mock cache strategy support

Layer / File(s) Summary
Cache strategy API and validation
src/plugin_system/testing/mocks.py, test/test_testing_mocks.py
Adds strategy lookup call tracking, delegates get_cached_data_with_strategy and save_cache to existing cache operations, and tests retrieval, defaults, missing keys, tracking, and saved-value interoperability.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding MockCacheManager cache helper methods in testing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mock-cache-manager-strategy-method

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

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.

@ChuckBuilds

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6edd80d and ee5df2a.

📒 Files selected for processing (2)
  • src/plugin_system/testing/mocks.py
  • test/test_testing_mocks.py

Comment thread src/plugin_system/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
@ChuckBuilds
ChuckBuilds merged commit 6499794 into main Jul 14, 2026
8 checks passed
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