test: add unit tests for general_extractor - #157
Conversation
PR Review: test: add unit tests for general_extractorExecutive Summary
Affected Areas: Business Impact: Improves regression safety for the heuristic memory extractor. Locks in current behavior for all 5 memory types. Flow Changes: None — no production code modified. Ratings
PR Health
Medium Priority Issues🎨 #1: Test file uses standalone functions instead of class-based groupingLocation: Every existing test file in this project groups tests into - def test_empty_text_returns_empty_list():
- assert extract_memories("") == []
-
- def test_short_paragraph_is_filtered_out():
- assert extract_memories("we decided") == []
+ class TestExtractMemoriesBasic:
+ def test_empty_text_returns_empty_list(self):
+ assert extract_memories("") == []
+
+ def test_short_paragraph_is_filtered_out(self):
+ assert extract_memories("we decided") == []Suggested groupings: Low Priority Issues🐛 #2:
|
Covers the public extract_memories API end to end. Until now the module had no dedicated tests even though CONTRIBUTING.md calls out extending coverage as a good first contribution. The tests hit each of the five memory types (decision, preference, milestone, problem, emotional), exercise the short-segment filter, the min_confidence threshold, the fenced-code-block skip inside _extract_prose, the speaker-turn splitter for Human / Assistant chat transcripts, the sequential chunk_index numbering, and the shape of each returned dict. The speaker-turn test uses three turns so it actually exercises _split_by_turns (the switch requires turn_count >= 3) instead of falling back to paragraph splitting. No production code changes.
c47eaf8 to
d8fa9c2
Compare
|
Applied the two specific findings:
Rebased on latest main, 12/12 tests still pass locally. Kept the standalone-function layout since the project already ships both styles ( |
|
Closing - upstream already has comprehensive test coverage for general_extractor (26 tests landed via the recent security-hardening merge). My 12 tests are fully redundant now. |
What does this PR do?
Adds a dedicated test suite for
mempalace/general_extractor.py. The module is a pure-heuristic, no-LLM, self-contained extractor that classifies text into decision / preference / milestone / problem / emotional memories, and until now it had no tests of its own. CONTRIBUTING.md explicitly calls out expanding test coverage as a good contribution, so this focuses on locking in the current behaviour with a small, fast test file.No production code changes.
Coverage added
tests/test_general_extractor.pyexercises:min_confidencethreshold behaviour (strict vs permissive)._extract_prose(a block full of decision words insidefences does not get classified as a decision).Human: ... Assistant: ...chat transcripts.chunk_indexnumbering across multiple segments.How to test
12 tests passing locally in ~0.06s.
Checklist
python -m pytest tests/test_general_extractor.py -v- 12 passed)ruff check .,ruff format --check .)