Description
The two core loader classes (LocalRepoLoader and UrlRepoLoader) in repo2readme/loaders/loader.py have zero test coverage. These are critical components — they handle all repository file loading and filtering logic. Any regression here breaks the entire tool.
Files
repo2readme/loaders/loader.py (full file, 144 lines)
tests/test_loader.py (needs to be created)
What Needs Testing
LocalRepoLoader
__init__: Verify parameters are stored correctly
_should_include: Test with include/exclude patterns, max file size
load():
- Loads files from a temp directory
- Correct
metadata fields (file_path, file_name, file_type, relative_path)
- Skips files exceeding
max_file_size_kb
- Filters directories via
os.walk dirs[:] mutation
- Raises
FileNotFoundError for invalid path
- Handles unreadable files gracefully (logs error, continues)
UrlRepoLoader
__init__: Verify parameters stored correctly
get_repo_name: Extract name from various URL formats
_should_include: Filter logic similar to LocalRepoLoader
load():
- Git clone via GitLoader
- Metadata correctness for loaded docs
- Temp directory creation/cleanup
cleanup(): Removes temp directory
Example Test Skeleton
import pytest
from pathlib import Path
from repo2readme.loaders.loader import LocalRepoLoader
def test_local_loader_loads_files(tmp_path):
# Create test files
main_py = tmp_path / "main.py"
main_py.write_text("print(hello)")
loader = LocalRepoLoader(str(tmp_path))
docs, root_path = loader.load()
assert len(docs) == 1
assert docs[0].metadata["file_name"] == "main.py"
assert docs[0].metadata["file_type"] == ".py"
assert root_path == str(tmp_path)
def test_local_loader_filters_by_size(tmp_path):
large_file = tmp_path / "large.bin"
large_file.write_text("x" * 300 * 1024)
loader = LocalRepoLoader(str(tmp_path), max_file_size_kb=200)
docs, _ = loader.load()
assert len(docs) == 0 # Should skip oversized file
Difficulty
Easy - Straightforward use of pytest + tmp_path fixtures, no mocking of LLMs required.
Impact
- Catches regressions in the file loading pipeline
- Ensures filter correctness (include/exclude patterns, file size limits)
- Prevents bugs in metadata propagation to the summarization stage
- Improves overall test coverage from ~25% to ~40%
Description
The two core loader classes (
LocalRepoLoaderandUrlRepoLoader) inrepo2readme/loaders/loader.pyhave zero test coverage. These are critical components — they handle all repository file loading and filtering logic. Any regression here breaks the entire tool.Files
repo2readme/loaders/loader.py(full file, 144 lines)tests/test_loader.py(needs to be created)What Needs Testing
LocalRepoLoader
__init__: Verify parameters are stored correctly_should_include: Test with include/exclude patterns, max file sizeload():metadatafields (file_path,file_name,file_type,relative_path)max_file_size_kbos.walkdirs[:] mutationFileNotFoundErrorfor invalid pathUrlRepoLoader
__init__: Verify parameters stored correctlyget_repo_name: Extract name from various URL formats_should_include: Filter logic similar to LocalRepoLoaderload():cleanup(): Removes temp directoryExample Test Skeleton
Difficulty
Easy - Straightforward use of pytest + tmp_path fixtures, no mocking of LLMs required.
Impact