mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-06-24 20:28:12 +02:00
refactor: remove source paths from PIFS
This commit is contained in:
parent
b9e30952ad
commit
dc4de3116f
22 changed files with 324 additions and 528 deletions
|
|
@ -7,7 +7,6 @@ def test_root_virtual_file_path_resolves_without_double_slash(tmp_path):
|
|||
filesystem = PageIndexFileSystem(workspace=tmp_path / "workspace")
|
||||
file_ref = filesystem.register_file(
|
||||
storage_uri="file:///tmp/root-source.txt",
|
||||
source_path="sources/root-source.txt",
|
||||
folder_path="/",
|
||||
external_id="doc_root_title",
|
||||
title="Root Title",
|
||||
|
|
@ -17,13 +16,12 @@ def test_root_virtual_file_path_resolves_without_double_slash(tmp_path):
|
|||
assert filesystem.store.resolve_file_ref("/Root Title") == file_ref
|
||||
|
||||
|
||||
def test_ambiguous_virtual_file_path_raises_clear_error(tmp_path):
|
||||
def test_nested_virtual_file_path_resolves_by_folder_and_title(tmp_path):
|
||||
from pageindex.filesystem import PageIndexFileSystem
|
||||
|
||||
filesystem = PageIndexFileSystem(workspace=tmp_path / "workspace")
|
||||
first_ref = filesystem.register_file(
|
||||
storage_uri="file:///tmp/first.txt",
|
||||
source_path="b/file.txt",
|
||||
folder_path="/a",
|
||||
external_id="doc_first",
|
||||
title="First",
|
||||
|
|
@ -31,26 +29,23 @@ def test_ambiguous_virtual_file_path_raises_clear_error(tmp_path):
|
|||
)
|
||||
second_ref = filesystem.register_file(
|
||||
storage_uri="file:///tmp/second.txt",
|
||||
source_path="second-source.txt",
|
||||
folder_path="/a/b",
|
||||
external_id="doc_second",
|
||||
title="file.txt",
|
||||
content="second content",
|
||||
)
|
||||
|
||||
with pytest.raises(KeyError, match="Ambiguous file target"):
|
||||
filesystem.store.resolve_file_ref("/a/b/file.txt")
|
||||
assert filesystem.store.resolve_file_ref("/a/b/file.txt") == second_ref
|
||||
|
||||
assert first_ref != second_ref
|
||||
|
||||
|
||||
def test_duplicate_source_path_target_raises_clear_error(tmp_path):
|
||||
def test_unknown_virtual_file_target_raises_clear_error(tmp_path):
|
||||
from pageindex.filesystem import PageIndexFileSystem
|
||||
|
||||
filesystem = PageIndexFileSystem(workspace=tmp_path / "workspace")
|
||||
first_ref = filesystem.register_file(
|
||||
storage_uri="file:///tmp/first.txt",
|
||||
source_path="shared/source.txt",
|
||||
folder_path="/first",
|
||||
external_id="doc_first",
|
||||
title="First",
|
||||
|
|
@ -58,14 +53,13 @@ def test_duplicate_source_path_target_raises_clear_error(tmp_path):
|
|||
)
|
||||
second_ref = filesystem.register_file(
|
||||
storage_uri="file:///tmp/second.txt",
|
||||
source_path="shared/source.txt",
|
||||
folder_path="/second",
|
||||
external_id="doc_second",
|
||||
title="Second",
|
||||
content="second content",
|
||||
)
|
||||
|
||||
with pytest.raises(KeyError, match="Ambiguous file target"):
|
||||
filesystem.store.resolve_file_ref("/shared/source.txt")
|
||||
with pytest.raises(KeyError, match="Unknown file target"):
|
||||
filesystem.store.resolve_file_ref("/shared/missing.txt")
|
||||
|
||||
assert first_ref != second_ref
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue