The frontend re-derived partition rank from the serialized type, so FIFO, socket, and device entries moved into the regular-file partition on non-default sorts. Emit workspace_sort_rank from list_dir, consume it in the rank helper, and keep it out of dir_signature.
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from api.workspace import dir_signature, list_dir
|
|
|
|
|
|
def test_directory_signature_is_metadata_only_and_changes_with_entries(tmp_path):
|
|
(tmp_path / "alpha.txt").write_text("one", encoding="utf-8")
|
|
|
|
entries = list_dir(tmp_path, ".")
|
|
sig1 = dir_signature(tmp_path, ".", entries)
|
|
|
|
assert isinstance(sig1, str)
|
|
assert len(sig1) == 64
|
|
assert all("mtime_ns" in entry for entry in entries)
|
|
|
|
(tmp_path / "beta.txt").write_text("two", encoding="utf-8")
|
|
entries2 = list_dir(tmp_path, ".")
|
|
sig2 = dir_signature(tmp_path, ".", entries2)
|
|
|
|
assert sig2 != sig1
|
|
|
|
|
|
def test_directory_signature_can_be_computed_from_supplied_entries(tmp_path):
|
|
(tmp_path / "alpha.txt").write_text("one", encoding="utf-8")
|
|
|
|
entries = list_dir(tmp_path, ".")
|
|
|
|
assert dir_signature(tmp_path, ".", entries) == dir_signature(tmp_path, ".", entries)
|
|
|
|
|
|
def test_directory_signature_ignores_workspace_sort_rank(tmp_path):
|
|
(tmp_path / "alpha.txt").write_text("one", encoding="utf-8")
|
|
entries = list_dir(tmp_path, ".")
|
|
changed = [dict(entry, workspace_sort_rank=1) for entry in entries]
|
|
|
|
assert dir_signature(tmp_path, ".", entries) == dir_signature(tmp_path, ".", changed)
|