aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-cli/tests/test_interactive.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-15 01:12:16 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-15 01:12:16 +0200
commit382fcc5f675f9942350013780335315757c245c5 (patch)
treea24ed8732c6d3971b071ed6af3c399d6142b79f4 /packages/meshbay-cli/tests/test_interactive.py
parent6f68bb6c1970e26de1f66c073ea5d7fecd21840d (diff)
downloadmeshbay-382fcc5f675f9942350013780335315757c245c5.tar.gz
feat(cli): rm, and Delete in the interactive mode
rm deletes files, resolved as get resolves paths and patterns, with the node's rule (design §5.4): the uploading account's devices, or the node's operator account. The whole run is checked against the index first (the entry's uploader_id, the role the join result gives this key): a file outside the rule, or a folder, refuses it before anything is asked or sent. Then one confirmation, or --yes. The node's challenge is checked against what was asked before it is signed. In the interactive mode, Delete on the right pane does the same, asked once per batch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-cli/tests/test_interactive.py')
-rw-r--r--packages/meshbay-cli/tests/test_interactive.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/packages/meshbay-cli/tests/test_interactive.py b/packages/meshbay-cli/tests/test_interactive.py
index 680b9e0..49180d5 100644
--- a/packages/meshbay-cli/tests/test_interactive.py
+++ b/packages/meshbay-cli/tests/test_interactive.py
@@ -157,3 +157,52 @@ async def test_a_read_only_folder_takes_no_upload(world):
await pilot.pause(0.3)
assert node.stored("share/mine.txt") is None
assert any("does not accept uploads" in n.message for n in app._notifications)
+
+
+async def test_delete_removes_what_is_yours_and_asks_first(world):
+ from fake_hub import USER_ID
+ hub, node, work = world
+ mine = node.add("share", "mine.txt", b"1", uploader_id=USER_ID)
+ theirs = node.add("share", "theirs.txt", b"2", uploader_id="someone-else")
+ assert await asyncio.to_thread(cli.main, ["--hub", "https://hub.test", "-u", USERNAME,
+ "--password", PASSPHRASE, "login"]) == 0
+ app = _app()
+ async with app.run_test(size=(120, 30)) as pilot:
+ await _until(pilot, lambda: isinstance(app.screen, MainScreen))
+ remote = app.screen.query_one(RemotePane)
+ await _open(pilot, remote, f"Family@{USERNAME}/")
+ await _open(pilot, remote, "share/")
+ await _until(pilot, lambda: "theirs.txt" in _names(remote))
+
+ # Somebody else's file, marked with one's own: nothing is deleted.
+ for name in ("mine.txt", "theirs.txt"):
+ remote.table.move_cursor(row=_names(remote).index(name))
+ await pilot.press("space")
+ await pilot.press("delete")
+ await _until(pilot, lambda: isinstance(app.screen, Choice))
+ assert "theirs.txt" in str(app.screen.message)
+ await pilot.click("#choice-ok")
+ assert mine["id"] in node.files and theirs["id"] in node.files
+
+ # One's own: asked, cancelled, asked again, deleted, and gone from the pane.
+ await _until(pilot, lambda: isinstance(app.screen, MainScreen))
+ remote.marks.clear()
+ remote.redraw()
+ remote.table.move_cursor(row=_names(remote).index("mine.txt"))
+ await pilot.press("delete")
+ await _until(pilot, lambda: isinstance(app.screen, Choice))
+ await pilot.click("#choice-cancel")
+ assert mine["id"] in node.files
+ await _until(pilot, lambda: isinstance(app.screen, MainScreen))
+ await pilot.press("delete")
+ await _until(pilot, lambda: isinstance(app.screen, Choice))
+ await pilot.click("#choice-delete")
+ await _until(pilot, lambda: mine["id"] not in node.files)
+ await _until(pilot, lambda: "mine.txt" not in _names(remote))
+ assert theirs["id"] in node.files
+
+ # On the left, Delete removes nothing of this machine's.
+ app.screen.query_one(LocalPane).table.focus()
+ await pilot.press("delete")
+ await pilot.pause(0.2)
+ assert any("select them on the right" in n.message for n in app._notifications)