feat: add unit tests for LocalRepoLoader and UrlRepoLoader functionality#38
feat: add unit tests for LocalRepoLoader and UrlRepoLoader functionality#38sagar-18-07-2006 wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a pytest suite covering ChangesRepository Loader Tests
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/test_loader.py (1)
42-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMock assertions verify invocation but not arguments across three tests. The shared root cause is using
assert_called_once()withoutassert_called_once_with(...), which confirms a mock was invoked but not that it received the correct parameters — regressions in argument passing would go undetected.
tests/test_loader.py#L42-L42: Intest_should_include, verifygithub_file_filterwas called with the correctrelative_path(e.g.,"a.py"),include_patterns,exclude_patterns,root_path, andmax_file_size_kb.tests/test_loader.py#L126-L126: Intest_url_should_include, verifygithub_file_filterreceivedrelative_path="src/main.py",root_path="/tmp/repo", and the expected pattern/size parameters.tests/test_loader.py#L154-L154: Intest_url_load_metadata, verifyGitLoaderwas constructed with the correctrepo_path,clone_url,branch, andfile_filterarguments.🤖 Prompt for 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. In `@tests/test_loader.py` at line 42, Replace the invocation-only mock assertions with argument-specific assert_called_once_with checks in tests/test_loader.py at lines 42-42, 126-126, and 154-154. In test_should_include, verify github_file_filter receives relative_path "a.py", include_patterns, exclude_patterns, root_path, and max_file_size_kb; in test_url_should_include, verify relative_path "src/main.py", root_path "/tmp/repo", and the expected pattern/size parameters; in test_url_load_metadata, verify GitLoader receives the expected repo_path, clone_url, branch, and file_filter arguments.
🤖 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 `@tests/test_loader.py`:
- Around line 129-154: Update test_url_load_metadata to call loader.cleanup()
after the assertions and mock_gitloader verification, ensuring the real
temporary directory created by loader.load() is removed while preserving the
existing metadata checks.
---
Nitpick comments:
In `@tests/test_loader.py`:
- Line 42: Replace the invocation-only mock assertions with argument-specific
assert_called_once_with checks in tests/test_loader.py at lines 42-42, 126-126,
and 154-154. In test_should_include, verify github_file_filter receives
relative_path "a.py", include_patterns, exclude_patterns, root_path, and
max_file_size_kb; in test_url_should_include, verify relative_path
"src/main.py", root_path "/tmp/repo", and the expected pattern/size parameters;
in test_url_load_metadata, verify GitLoader receives the expected repo_path,
clone_url, branch, and file_filter arguments.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
|
@sagar-18-07-2006 the code changed so update yourself codebase and then create new tests cases |
Description
Closes #30
Summary
This PR adds a comprehensive test suite for
repo2readme/loaders/loader.py, covering bothLocalRepoLoaderandUrlRepoLoader.These loader classes are core components responsible for loading repository files, applying include/exclude filters, enriching document metadata, and managing temporary repositories. Previously, they had no dedicated unit tests.
What's Included
LocalRepoLoader_should_include()filtering logic.file_path,file_name,file_type, andrelative_path).FileNotFoundErrorwhen the repository path does not exist.UrlRepoLoaderget_repo_name()._should_include().GitLoaderto test repository loading without performing real Git clones.Benefits
GitLoaderandTextLoader.