mempalace/tests
Mikhail Valentsev a2432a3245
fix: parse Claude.ai privacy export with messages key and sender field (#677) (#685)
* fix: parse Claude.ai privacy export with messages key and sender field (#677)

The privacy-export branch in _try_claude_ai_json only checked for the
"chat_messages" key, missing exports that use "messages" instead.  It
also only read the "role" field while real privacy exports use "sender".
Both gaps caused the file to fall through to plain-text, producing a
single giant drawer.

Changes:
- Accept "messages" alongside "chat_messages" in the conversation-object
  guard and inner extraction.
- Accept "sender" alongside "role" as the author field.
- Fall back to a top-level "text" key when content blocks are empty.
- Produce one transcript per conversation instead of concatenating all
  conversations into a single blob.
- Extract shared logic into _collect_claude_messages helper.
- Add 6 regression tests covering each variant.

* style: apply ruff format to normalize.py

* fix: guard against null text field in Claude.ai export parsing

item.get("text", "").strip() crashes when "text" is explicitly null
in the JSON (legal and observed in some exports). Use
(item.get("text") or "").strip() and add a regression test.

---------

Co-authored-by: Igor Lins e Silva <4753812+igorls@users.noreply.github.com>
2026-04-13 02:11:03 -03:00
..
benchmarks fix: format test_layers_bench.py with ruff to pass CI lint 2026-04-09 08:24:51 +03:00
conftest.py fix: close KnowledgeGraph SQLite connections in test fixtures (#450) 2026-04-11 23:14:23 -07:00
test_backends.py fix: auto-repair BLOB seq_ids from chromadb 0.6→1.5 migration (#664) 2026-04-11 23:06:01 -07:00
test_cli.py fix: harden palace security checks 2026-04-12 22:19:58 -03:00
test_config.py fix: allow Unicode in sanitize_name() — Latvian, CJK, Cyrillic (#637) (#683) 2026-04-12 14:23:34 -07:00
test_config_extra.py test: bring coverage to 85%, set threshold to 85, reset version to 3.0.11 2026-04-08 21:38:12 +03:00
test_convo_miner.py fix: prevent convo_miner from re-processing 0-chunk files on every run (#654) (#732) 2026-04-12 14:25:34 -07:00
test_convo_miner_unit.py fix: store full AI response in convo_miner exchange chunking (#695) 2026-04-12 14:23:52 -07:00
test_dedup.py style: ruff format 2026-04-10 08:49:35 -07:00
test_dialect.py fix: align cmd_compress dict keys with compression_stats() return values (#569) 2026-04-11 16:16:31 -07:00
test_entity_detector.py test: bring coverage to 85%, set threshold to 85, reset version to 3.0.11 2026-04-08 21:38:12 +03:00
test_entity_registry.py test: add comprehensive test coverage (35% → 58%, threshold 50%) 2026-04-08 20:54:56 +03:00
test_exporter.py feat: new MCP tools — get/list/update drawer, hook settings, export (resolves #635) (#667) 2026-04-11 21:25:04 -07:00
test_general_extractor.py style: format test files with ruff 2026-04-08 21:08:49 +03:00
test_hooks_cli.py fix: ruff format test_hooks_cli.py and test_knowledge_graph.py 2026-04-08 15:12:12 -03:00
test_instructions_cli.py test: add comprehensive test coverage (35% → 58%, threshold 50%) 2026-04-08 20:54:56 +03:00
test_knowledge_graph.py fix: ruff format test_hooks_cli.py and test_knowledge_graph.py 2026-04-08 15:12:12 -03:00
test_knowledge_graph_extra.py test: bring coverage to 85%, set threshold to 85, reset version to 3.0.11 2026-04-08 21:38:12 +03:00
test_layers.py Мempalace backend seam (#413) 2026-04-11 16:16:49 -07:00
test_mcp_server.py fix: detect mtime changes in _get_client to prevent stale HNSW index (#757) 2026-04-13 01:53:13 -03:00
test_migrate.py chore: clarify security guardrails 2026-04-12 22:19:58 -03:00
test_miner.py fix: mine --dry-run TypeError on files with room=None (#586) (#687) 2026-04-12 14:23:44 -07:00
test_normalize.py fix: parse Claude.ai privacy export with messages key and sender field (#677) (#685) 2026-04-13 02:11:03 -03:00
test_onboarding.py test: bring coverage to 85%, set threshold to 85, reset version to 3.0.11 2026-04-08 21:38:12 +03:00
test_palace_graph.py style: format test files with ruff 2026-04-08 21:08:49 +03:00
test_query_sanitizer.py fix: make quote trimming explicit 2026-04-12 22:19:58 -03:00
test_repair.py test: add 33 tests for repair.py and dedup.py 2026-04-10 08:45:27 -07:00
test_room_detector_local.py fix: skip unreachable reparse points in detect_rooms_from_folders (#558) 2026-04-11 16:16:06 -07:00
test_searcher.py Мempalace backend seam (#413) 2026-04-11 16:16:49 -07:00
test_spellcheck.py style: format test files with ruff 2026-04-08 21:08:49 +03:00
test_spellcheck_extra.py test: bring coverage to 85%, set threshold to 85, reset version to 3.0.11 2026-04-08 21:38:12 +03:00
test_split_mega_files.py test: expand coverage to 70%, fix mcp_server CI crash (threshold 60%) 2026-04-08 21:07:03 +03:00
test_version_consistency.py fix: unify package and MCP version reporting 2026-04-07 08:53:25 +01:00