diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-08 01:11:38 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-08 01:11:38 +0200 |
| commit | ed0c680790950354f15fb5835e1d7b213efa1bf8 (patch) | |
| tree | 59af376652005a0b02c95945c1df6044882a94e5 /packages/meshbay-node/tests/test_roots.py | |
| parent | 4c8e4fb8b8fcd3f78bf4e3e736a058c351aac973 (diff) | |
| download | meshbay-ed0c680790950354f15fb5835e1d7b213efa1bf8.tar.gz | |
fix(node): name a root after its drive when its basename is taken
Two drives with a folder of the same name made the second add fail,
and no screen could supply another name. add_root now names it
"Name (H)" or "Name (parent)"; a name the operator typed is still
refused on a clash.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/tests/test_roots.py')
| -rw-r--r-- | packages/meshbay-node/tests/test_roots.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_roots.py b/packages/meshbay-node/tests/test_roots.py index 9a403ff..0fe9f03 100644 --- a/packages/meshbay-node/tests/test_roots.py +++ b/packages/meshbay-node/tests/test_roots.py @@ -8,13 +8,17 @@ copy breaks the other". """ +from pathlib import PurePosixPath, PureWindowsPath + import pytest +from meshbay_common.paths import fold from meshbay_common.protocol import IndexEntry from meshbay_node.roots import ( SAFE_UPLOAD_NAME, RootError, RootSet, _free_name, + distinct_name, entry_abs_path, safe_subdir, ) @@ -51,6 +55,18 @@ def test_two_roots_cannot_share_a_name(tmp_path): _spec(tmp_path / "b" / "Films")]) +def test_a_distinct_name_says_where_the_folder_is(): + taken = {fold("Archives")} + assert distinct_name(PureWindowsPath(r"H:\Archives"), taken) == "Archives (H)" + assert distinct_name(PurePosixPath("/mnt/b/Films"), {fold("Films")}) == "Films (b)" + assert distinct_name(PurePosixPath("/mnt/b/Films"), set()) == "Films" + + +def test_a_distinct_name_counts_when_where_is_taken_too(): + taken = {fold("Films"), fold("Films (b)")} + assert distinct_name(PurePosixPath("/mnt/b/Films"), taken) == "Films (2)" + + def test_names_clash_without_regard_to_case(tmp_path): """ `Films` and `films` are one directory on NTFS and exFAT, which is where most |