summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-cli/tests/test_interactive.py
diff options
context:
space:
mode:
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)