コード例 #1
0
async def test_fast_forward_on_offline_during_sync(autojump_clock,
                                                   server_factory, backend,
                                                   client_factory, alice,
                                                   alice2):
    # Create two servers to be able to turn offline a single one
    async with server_factory(
            backend.handle_client) as server1, server_factory(
                backend.handle_client) as server2:

        # Given the clients are initialized while the backend is online, we are
        # guaranteed they are connected
        async with client_factory(
                config={"backend_addr": server1.addr}
        ) as alice_client, client_factory(
                config={"backend_addr": server2.addr}) as alice2_client2:
            await alice_client.login(alice)
            await alice2_client2.login(alice2)

            # TODO: shouldn't need this...
            await trio.testing.wait_all_tasks_blocked(cushion=0.1)

            async with wait_for_entries_synced(alice2_client2,
                                               ["/"]), wait_for_entries_synced(
                                                   alice_client,
                                                   ("/", "/foo.txt")):
                with freeze_time("2000-01-02"):
                    await alice_client.user_fs.touch("/foo.txt")

                with freeze_time("2000-01-03"):
                    await alice_client.user_fs.file_write("/foo.txt", b"v1")

                # Sync should be done in the background by the sync monitor
                ########### shouldn't need to do that... #######
                await alice_client.user_fs.sync("/foo.txt")

            # TODO: shouldn't need this...
            await trio.testing.wait_all_tasks_blocked(cushion=0.1)

            # client goes offline, other client2 is still connected to backend
            async with wait_for_entries_synced(alice_client,
                                               ("/", "/foo.txt")):
                stat2 = await alice2_client2.user_fs.stat("/foo.txt")
                with offline(server1.addr):

                    with freeze_time("2000-01-04"):
                        await alice2_client2.user_fs.file_write(
                            "/foo.txt", b"v2")
                        await alice2_client2.user_fs.folder_create("/bar")

                    async with wait_for_entries_synced(
                            alice2_client2, ("/", "/bar", "/foo.txt")):
                        await alice2_client2.user_fs.sync()

            for path in ("/", "/bar", "/foo.txt"):
                stat = await alice_client.user_fs.stat(path)
                stat2 = await alice2_client2.user_fs.stat(path)
                assert stat2 == stat
コード例 #2
0
async def test_claim_user_offline(aqtbot, gui, autoclose_dialog,
                                  running_backend, alice_invite, monkeypatch,
                                  qt_thread_gateway):
    claim_w = await _gui_ready_for_claim(aqtbot, gui, alice_invite,
                                         monkeypatch, qt_thread_gateway)

    with offline(alice_invite["addr"]):
        async with aqtbot.wait_signal(claim_w.claim_error):
            await aqtbot.mouse_click(claim_w.button_claim,
                                     QtCore.Qt.LeftButton)

    assert len(autoclose_dialog.dialogs) == 2
    assert autoclose_dialog.dialogs[1][0] == "Error"
    assert autoclose_dialog.dialogs[1][1] == "NOP"
コード例 #3
0
 def _offline_for(device_id):
     return offline(addr_with_device_subdomain(server.addr, device_id))
コード例 #4
0
 def offline(self):
     return offline(self.addr)