mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-22 23:31:12 +02:00
test: tidy concept-identity roundtrip docstring
This commit is contained in:
parent
c99a8154c0
commit
9a18392484
1 changed files with 27 additions and 0 deletions
|
|
@ -79,6 +79,33 @@ class TestDocToVirtualPath:
|
|||
assert path == f"{DOCUMENTS_ROOT}/notes/A.xml"
|
||||
|
||||
|
||||
class TestConceptIdentityRoundTrip:
|
||||
"""A document's virtual path must parse back to the same (folder, title) - the
|
||||
OKF path-identity guarantee at the grammar level, no DB required."""
|
||||
|
||||
def test_folder_nested_document_roundtrips(self):
|
||||
index = PathIndex(folder_paths={5: f"{DOCUMENTS_ROOT}/Research/AI"})
|
||||
path = doc_to_virtual_path(
|
||||
doc_id=2, title="My Note", folder_id=5, index=index
|
||||
)
|
||||
assert path == f"{DOCUMENTS_ROOT}/Research/AI/My Note.xml"
|
||||
folder_parts, title = parse_documents_path(path)
|
||||
assert folder_parts == ["Research", "AI"]
|
||||
assert title == "My Note"
|
||||
|
||||
def test_colliding_title_roundtrips_to_base_title(self):
|
||||
# Second doc with the same title gets a " (<id>)" suffix; parsing the
|
||||
# path must strip the disambiguator and recover the original title.
|
||||
index = PathIndex(occupants={f"{DOCUMENTS_ROOT}/Hello.xml": 7})
|
||||
path = doc_to_virtual_path(
|
||||
doc_id=8, title="Hello", folder_id=None, index=index
|
||||
)
|
||||
assert path == f"{DOCUMENTS_ROOT}/Hello (8).xml"
|
||||
folder_parts, title = parse_documents_path(path)
|
||||
assert folder_parts == []
|
||||
assert title == "Hello"
|
||||
|
||||
|
||||
class TestParseDocumentsPath:
|
||||
def test_extracts_folder_parts_and_title(self):
|
||||
parts, title = parse_documents_path(f"{DOCUMENTS_ROOT}/foo/bar/baz.xml")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue