diff options
Diffstat (limited to 'packages/meshbay-cli/tests/test_e2e_local.py')
| -rw-r--r-- | packages/meshbay-cli/tests/test_e2e_local.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/meshbay-cli/tests/test_e2e_local.py b/packages/meshbay-cli/tests/test_e2e_local.py index 988fb38..8ce3ebc 100644 --- a/packages/meshbay-cli/tests/test_e2e_local.py +++ b/packages/meshbay-cli/tests/test_e2e_local.py @@ -888,3 +888,31 @@ def test_a_member_joins_links_devices_shares_with_browsers_and_leaves(world): assert bob(world, "bob1", "ls", f"{group}/share").returncode == 0 for home in ("bob1", "bob2", "bob3"): assert bob(world, home, "logout").returncode == 0 + + +def test_search_finds_a_file_and_get_takes_its_path(world, tmp_path): + """The path `search` prints is the one `get` takes, accents, spaces, an + apostrophe and a group name holding a / and an @ included.""" + deadline = time.monotonic() + 90 + while True: + r = cli(world, "--hub", world["hub_url"], "-u", USERNAME, "login", + "--password-file", "-", stdin=PASSPHRASE + "\n", home="cli-search") + if r.returncode == 0: + break + assert "Too many attempts" in r.stderr and time.monotonic() < deadline, r.stderr + time.sleep(5) + r = cli(world, "search", "PLAGE", "ouest", home="cli-search") + # After a test that withdrew the node's copy, this machine is a new device: + # search names the group and its code instead of waiting (exit 4). + if r.returncode == 4 and "waits to be approved" in r.stderr: + code = re.search(r"\(([0-9A-Z]{4}-[0-9A-Z]{4})\)", r.stderr).group(1) + asyncio.run(world["app"].approve(code)) + r = cli(world, "search", "PLAGE", "ouest", home="cli-search") + assert r.returncode == 0, r.stderr + [path] = r.stdout.splitlines() + assert path == f"{_handle()}/share/2024/été à la mer/plage de l'ouest.jpg" + r = cli(world, "get", path, "-o", str(tmp_path) + "/", home="cli-search") + assert r.returncode == 0, r.stderr + assert (tmp_path / "plage de l'ouest.jpg").stat().st_size == 3000 + r = cli(world, "search", "no-such-thing-anywhere", home="cli-search") + assert r.returncode == 3 and "Nothing found" in r.stderr |