Skip to content

test: cover git cache edge cases without network - #277

Merged
ulises-jeremias merged 2 commits into
Create-Python-App:mainfrom
AshSgDe29071999:test/cache-edge-cases
Aug 9, 2026
Merged

test: cover git cache edge cases without network#277
ulises-jeremias merged 2 commits into
Create-Python-App:mainfrom
AshSgDe29071999:test/cache-edge-cases

Conversation

@AshSgDe29071999

@AshSgDe29071999AshSgDe29071999 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Cache helpers needed more edge-case coverage without network access.

Changes

  • Empty entry / missing meta returns None
  • Corrupt .cpa-cache.json raises cleanly
  • Invalid CPA_REFRESH_AFTER_HOURS falls back to 24h
  • _should_refresh mode matrix

Closes#267

Summary by CodeRabbit

  • Tests
    • Added coverage for empty or corrupted cache metadata.
    • Added validation tests for invalid refresh interval settings.
    • Added tests for cache refresh-mode behavior.

Closes#267
Empty cache dir, corrupt metadata, invalid refresh-hours env, and
refresh-mode decision matrix for CacheMeta.
@coderabbitai

coderabbitaiBot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 22866ed8-69f4-4921-9c2c-4e50a29b7ee3

📥 Commits

Reviewing files that changed from the base of the PR and between 38baf01 and 5c512c3.

📒 Files selected for processing (1)
  • packages/create-python-app-core/tests/test_git_cache.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/create-python-app-core/tests/test_git_cache.py

📝 Walkthrough

Walkthrough

The pull request adds unit tests for missing and corrupt cache metadata, invalid refresh interval configuration, and refresh decisions across supported modes.

Changes

Git cache test coverage

Layer / File(s)Summary
Cache metadata and refresh behavior
packages/create-python-app-core/tests/test_git_cache.py
Tests cover missing and corrupt metadata, invalid CPA_REFRESH_AFTER_HOURS fallback, and refresh decisions for missing, manual, always-refresh, and stale metadata.

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

Suggested reviewers:ulises-jeremias

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Linked Issues check⚠️ WarningThe tests cover empty and corrupt cache states, but no evidence covers missing remote references or permission errors required by [#267].Add offline tests for missing remote references and permission errors using temporary directories or fixtures.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly describes the added offline tests for Git cache edge cases.
Out of Scope Changes check✅ PassedThe changes remain within the linked issue scope of adding offline unit tests for Git cache edge cases [#267].
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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 `@packages/create-python-app-core/tests/test_git_cache.py`:
- Around line 146-155: Update test_read_cache_meta_corrupt_json to restrict
pytest.raises to json.JSONDecodeError and CpaError, removing the generic
TypeError and ValueError alternatives while preserving the corrupt-JSON fixture
and read_cache_meta call.
- Around line 140-143: Update test_read_cache_meta_empty_dir to create an
existing empty cache directory under tmp_path and assert read_cache_meta returns
None for it, while retaining a separate assertion that a nonexistent path also
returns None.
- Around line 165-173: Add an assertion in test_should_refresh_modes for the
fresh meta instance with "stale" mode, verifying _should_refresh returns False;
retain the existing stale-metadata assertion that returns True.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 52bd2949-1482-4533-ab27-638920fdd45b

📥 Commits

Reviewing files that changed from the base of the PR and between bba4586 and 38baf01.

📒 Files selected for processing (1)
  • packages/create-python-app-core/tests/test_git_cache.py

Comment threadpackages/create-python-app-core/tests/test_git_cache.py
Comment threadpackages/create-python-app-core/tests/test_git_cache.py
Comment threadpackages/create-python-app-core/tests/test_git_cache.py
@ulises-jeremias

Copy link
Copy Markdown
Member

@AshSgDe29071999 hey! thanks for your contribution here!

CodeRabbit just left some review comments. Please address those and I'll run the CI and check after that 😊

You can also join the community Discord for quick questions and coordination: Discord 🥳

Cover empty existing cache dirs separately from missing paths, narrow
corrupt-JSON exceptions to JSONDecodeError/CpaError, and assert fresh
metadata does not refresh under stale mode.
@AshSgDe29071999

Copy link
Copy Markdown
ContributorAuthor

Addressed the CodeRabbit review comments on packages/create-python-app-core/tests/test_git_cache.py:

  • test_read_cache_meta_empty_dir now covers an existing empty cache directory and a missing path separately
  • Corrupt JSON assertion narrowed to json.JSONDecodeError and CpaError only
  • test_should_refresh_modes now asserts fresh metadata does not refresh under "stale" mode (still asserts old metadata does)

Ready for another look whenever you have a chance.

@AshSgDe29071999

Copy link
Copy Markdown
ContributorAuthor

@ulises-jeremias — CodeRabbit’s three review notes on packages/create-python-app-core/tests/test_git_cache.py are applied (commit 5c512c3):

  1. Empty cache dirtest_read_cache_meta_empty_dir asserts both an existing empty entry directory and a missing path return None
  2. Narrow exceptions — corrupt JSON expects only (json.JSONDecodeError, CpaError)
  3. Stale-mode fresh metaassert _should_refresh(meta, "stale") is False for fresh metadata (still asserts old meta refreshes)

Ready for CI whenever you have a moment. Thanks!

@ulises-jeremias
ulises-jeremias merged commit 6cd61c6 into Create-Python-App:mainAug 9, 2026
15 checks passed
Sign up for freeto 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.

test: add unit tests for cache module edge cases

2 participants

@AshSgDe29071999@ulises-jeremias