From 4e30c512ca569145b1d753d95010e7e28c63240e Mon Sep 17 00:00:00 2001 From: Research Assistant Date: Thu, 7 May 2026 19:03:04 +0800 Subject: [PATCH] fix(46-index-path-resolution): update tests for removed LIBRARY_RECORDS and config-resolved paths - test_base_views.py: Replace LIBRARY_RECORDS placeholder tests with LITERATURE/CONTROL_DIR - test_migration.py: Use config-resolved lit_rel instead of hardcoded 'Literature/' prefix --- tests/test_base_views.py | 42 +++++++++++++++++++++++++--------------- tests/test_migration.py | 7 ++++--- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/tests/test_base_views.py b/tests/test_base_views.py index 8eb4fa46..af307ad3 100644 --- a/tests/test_base_views.py +++ b/tests/test_base_views.py @@ -90,29 +90,39 @@ class TestBuildBaseViews: class TestSubstituteConfigPlaceholders: - def test_substitutes_library_records(self, tmp_path): - content = "${LIBRARY_RECORDS}/骨科" + def test_substitutes_literature(self, tmp_path): + content = "${LITERATURE}/骨科" vault = tmp_path / "Vault" vault.mkdir() - lib_rec = vault / "03_Resources" / "LiteratureControl" / "library-records" - lib_rec.mkdir(parents=True) - result = substitute_config_placeholders(content, {"library_records": lib_rec, "vault": vault}) - assert "${LIBRARY_RECORDS}" not in result - assert "03_Resources/LiteratureControl/library-records" in result + lit = vault / "Resources" / "Literature" + lit.mkdir(parents=True) + result = substitute_config_placeholders(content, {"literature": lit, "vault": vault}) + assert "${LITERATURE}" not in result + assert "Resources/Literature" in result + + def test_substitutes_control_dir(self, tmp_path): + content = "${CONTROL_DIR}/records" + vault = tmp_path / "Vault" + vault.mkdir() + ctrl = vault / "System" + ctrl.mkdir() + result = substitute_config_placeholders(content, {"control": ctrl, "vault": vault}) + assert "${CONTROL_DIR}" not in result + assert "System/records" in result def test_substitutes_multiple_placeholders(self, tmp_path): - content = "${LIBRARY_RECORDS} and ${LITERATURE}" + content = "${LITERATURE} and ${CONTROL_DIR}" vault = tmp_path / "Vault" vault.mkdir() - lib_rec = vault / "LR" lit = vault / "LIT" - lib_rec.mkdir() + ctrl = vault / "CTRL" lit.mkdir() + ctrl.mkdir() result = substitute_config_placeholders( - content, {"library_records": lib_rec, "literature": lit, "vault": vault} + content, {"literature": lit, "control": ctrl, "vault": vault} ) - assert "${LIBRARY_RECORDS}" not in result assert "${LITERATURE}" not in result + assert "${CONTROL_DIR}" not in result def test_unknown_placeholder_unchanged(self): content = "${UNKNOWN_PLACEHOLDER}/骨科" @@ -120,10 +130,10 @@ class TestSubstituteConfigPlaceholders: assert "${UNKNOWN_PLACEHOLDER}" in result def test_backslash_conversion(self, tmp_path): - content = "${LIBRARY_RECORDS}" + content = "${LITERATURE}" vault = tmp_path / "Vault" vault.mkdir() - lib_rec = vault / "LR" - lib_rec.mkdir() - result = substitute_config_placeholders(content, {"library_records": lib_rec, "vault": vault}) + lit = vault / "LR" + lit.mkdir() + result = substitute_config_placeholders(content, {"literature": lit, "vault": vault}) assert "\\" not in result # Should use forward slash diff --git a/tests/test_migration.py b/tests/test_migration.py index b53e635d..912085c2 100644 --- a/tests/test_migration.py +++ b/tests/test_migration.py @@ -363,10 +363,11 @@ class TestBuildEntryWorkspaceWrite: assert "title:" in content, "Frontmatter should contain title" assert "zotero_key:" in content, "Frontmatter should contain zotero_key" - # Verify entry has workspace paths - expected_root = f"Literature/骨科/{key} - {title_slug}/" + # Verify entry has workspace paths — config-resolved (Phase 46: PATH-01) + lit_rel = str(paths["literature"].relative_to(vault)).replace("\\", "/") + expected_root = f"{lit_rel}/骨科/{key} - {title_slug}/" assert entry["paper_root"] == expected_root - assert entry["main_note_path"].startswith(f"Literature/骨科/{key} - {title_slug}/") + assert entry["main_note_path"].startswith(f"{lit_rel}/骨科/{key} - {title_slug}/") assert entry["ai_path"] == f"{expected_root}ai/" def test_build_entry_flat_fallback_for_unmigrated_paper(