Skip to content

Commit aa5d276

Browse files
GeneAIclaude
authored andcommitted
test: Add comprehensive unit tests for summarize module
Added 46 new tests for memdocs/summarize.py: - TestSummarizerInit: API key, model, max_tokens initialization - TestSummarizerRepr: Masked API key representation - TestExtractYaml: YAML extraction from Claude responses - TestBuildPrompt: Prompt construction with context - TestBuildDocumentIndex: DocumentIndex building from YAML - TestGenerateMarkdown: Markdown generation from DocumentIndex - TestSummarize: Full summarization with mocked Claude API - TestRateLimiting: Rate limiter behavior - TestEdgeCases: Empty files, many symbols, special characters Coverage improvements: - summarize.py: 12% → 100% (+88%) - security.py: 97% → 98% - Overall: 79% → 85% (+6%) Also fixed test_validate_path_runtime_error to work with Python 3.10+ by using MagicMock instead of Path subclass. Total tests: 335 → 381 (+46 tests) All tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent b25b20c commit aa5d276

File tree

2 files changed

+863
-6
lines changed

2 files changed

+863
-6
lines changed

tests/unit/test_security.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,15 @@ def test_validate_path_with_string_containing_null(self, tmp_path: Path):
9999
validated = PathValidator.validate_path(test_path)
100100
assert validated.is_absolute()
101101

102-
@pytest.mark.skip(reason="Path subclassing incompatible across Python versions")
103102
def test_validate_path_runtime_error(self, tmp_path: Path, monkeypatch):
104103
"""Test handling of RuntimeError during path resolution."""
104+
from unittest.mock import MagicMock
105105

106106
# Create a mock path that will raise RuntimeError on resolve
107-
class FailingPath(Path):
108-
def resolve(self, strict=False):
109-
raise RuntimeError("Simulated runtime error")
110-
111-
failing_path = FailingPath(tmp_path / "test.py")
107+
failing_path = MagicMock(spec=Path)
108+
failing_path.resolve.side_effect = RuntimeError("Simulated runtime error")
109+
# Make it look like a valid path for type checks
110+
failing_path.__class__ = Path
112111

113112
with pytest.raises(ValueError, match="Invalid path"):
114113
PathValidator.validate_path(failing_path)

0 commit comments

Comments
 (0)