Skip to content

test: expand test suite from 21 to 218 tests covering all modules - #149

Closed
s0j0hn wants to merge 22 commits into
MemPalace:mainfrom
s0j0hn:feat/test-suite-expansion
Closed

test: expand test suite from 21 to 218 tests covering all modules#149
s0j0hn wants to merge 22 commits into
MemPalace:mainfrom
s0j0hn:feat/test-suite-expansion

Conversation

@s0j0hn

@s0j0hn s0j0hn commented Apr 7, 2026

Copy link
Copy Markdown

Summary

  • Add 13 new test files covering every previously-untested module: knowledge_graph, palace_graph, searcher, layers, dialect, entity_detector, entity_registry, general_extractor, room_detector_local, mcp_server, spellcheck, split_mega_files, version_consistency
  • Fix resource leaks in test_config (temp dirs never cleaned, env var leak) and test_convo_miner (cleanup outside try/finally)
  • Expand test_normalize from 3 to 15 tests covering all 5 chat formats, privacy export, Slack username fallback, mixed content, IOError path
  • Expand test_convo_miner from 1 to 11 tests covering general extract mode, chunking edge cases, room detection, scan filtering
  • Expand test_mcp_server with duplicate checking, graph traversal tools, graph stats
  • Expand test_knowledge_graph with seed_from_entity_facts, NULL date queries, empty results
  • Expand test_entity_registry with learn_from_text auto-discovery, disambiguation tie, mocked Wikipedia lookup
  • Expand test_dialect with zettel encoding, file encoding with tunnels, count_tokens
  • Add shared conftest.py with HOME isolation, tmp_dir, palace_path, populated_palace, config, kg, seeded_kg fixtures
  • Simplify after code review: extract helpers, convert MCP patching to yield fixture, remove redundant assertions and comments

Before: 4 test files, 21 tests
After: 17 test files, 218 tests — all passing in ~8s

Test plan

  • pytest tests/ -v — 218 passed, 0 failures
  • ruff check tests/ — all checks passed
  • ruff format --check tests/ — all files formatted
  • No API keys or network access required

🤖 Generated with Claude Code

@s0j0hn

s0j0hn commented Apr 7, 2026

Copy link
Copy Markdown
Author

Do what you want with this @bensig @milla-jovovich

Jan and others added 15 commits April 7, 2026 23:24
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… assertions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…content

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n, stats

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…de filtering

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ndancy

- Extract _make_collection helper in test_palace_graph (removes 4 inline ChromaDB setups)
- Convert MCP server patching to a pytest fixture with yield (safer cleanup)
- Replace magic 19 with len(mcp_server.TOOLS)
- Prefix local write_file helpers with _ (not importable from conftest without __init__.py)
- Fix test_disambiguate_concept_context to actually test concept path (was duplicate of person test)
- Remove redundant assertion in test_layers (len > 0 implied by string-contains check)
- Remove unnecessary what-not-why comments across 5 files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@s0j0hn
s0j0hn force-pushed the feat/test-suite-expansion branch from fff5b58 to 600a8b5 Compare April 7, 2026 21:28
Jan and others added 5 commits April 7, 2026 23:32
…can filtering

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…learn, mock wikipedia

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…k, graph tools

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@s0j0hn s0j0hn changed the title test: expand test suite from 21 to 137 tests covering all modules test: expand test suite from 21 to 218 tests covering all modules Apr 7, 2026
@mvalentsev

Copy link
Copy Markdown
Contributor

I opened #157 earlier with a smaller focused test file for general_extractor only — black-box coverage against the public extract_memories API (empty input, the five memory types at the default min_confidence, chunk index sequencing, the fenced-code-block skip, speaker-turn splitting with type assertions, and the return-dict shape). It might be worth looking at the two side by side: this one exercises some private helpers (_get_sentiment, _has_resolution, _is_code_line, _extract_prose, _split_into_segments) which #157 deliberately avoids to stay robust to refactors.

If either approach ends up getting merged, happy to rebase the other on top or drop the overlapping file so there's no conflict.

Jan added 2 commits April 10, 2026 15:27
Main had independently expanded the test suite (commits 03e9b57, e24d8ca),
often producing strict supersets of the tests on this branch. Resolution
strategy:

- test_convo_miner.py: kept ours (11 tests vs main's 1)
- test_spellcheck.py: merged — kept our 49 _should_skip/user_text tests,
  appended main's 8 unique tests for _get_system_words, spellcheck_transcript,
  and spellcheck_transcript_line
- test_normalize, test_palace_graph, test_searcher, test_layers,
  test_entity_detector, test_entity_registry, test_general_extractor,
  test_mcp_server, test_dialect: kept main's versions (supersets or more
  comprehensive mocking)

Stripped unused pytest imports (ruff) and applied ruff format to
conftest.py and test_spellcheck.py.

582 tests passing, ruff clean.
Missed during the origin/main merge resolution — ruff caught it
post-commit. No behavior change.
@bensig

bensig commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Thanks for the test expansion work. Coverage was bumped to 85% in #281 (tmuskal) which overlaps significantly. If there are tests here that aren't covered, a focused follow-up would be great.

@bensig bensig closed this Apr 11, 2026
Sign up for free to 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.

3 participants