Exemple #1
0
def test_complete_scenario_synchronization_from_zero(nuxeo_url, exe, server,
                                                     tmp):
    """Automate things:
        - bind a server
        - bind a root
        - sync data
        - unbind the root
        - unbind the server
    """

    folder = tmp()
    assert not folder.is_dir()
    local_folder = f'--local-folder="{str(folder)}"'

    ws = None

    try:
        # 1st, bind the server
        args = f"Administrator {nuxeo_url} {local_folder} --password Administrator"
        assert bind(exe, args)
        assert folder.is_dir()

        # 2nd, create a workspace
        new = Document(
            name="sync and stop",
            type="Workspace",
            properties={"dc:title": "sync and stop"},
        )
        ws = server.documents.create(new, parent_path=env.WS_DIR)

        # 3rd, bind the root (e.g.: enable the sync of the workspace)
        args = f'bind-root "{ws.path}" {local_folder}'
        assert launch(exe, args, wait=5)

        # 4th, sync and quit
        assert launch(exe, "console --sync-and-quit", wait=40)

        # Check
        assert (folder / ws.title).is_dir()

        # Unbind the root
        args = f'unbind-root "{ws.path}" {local_folder}'
        assert launch(exe, args)

        # Unbind the server
        assert unbind(exe, local_folder)
    finally:
        if ws:
            ws.delete()

        assert launch(exe, f"clean-folder {local_folder}")

        os.chmod(folder, stat.S_IWUSR)
        shutil.rmtree(folder)
        assert not os.path.isdir(folder)
Exemple #2
0
    def _make(
        title: str = "",
        nature: str = "Folder",
        parent: str = env.WS_DIR,
        enable_sync: bool = False,
    ):
        title = title or str(uuid4())
        new = Document(name=title, type=nature, properties={"dc:title": title})
        obj = server.documents.create(new, parent_path=env.WS_DIR)
        request.addfinalizer(obj.delete)
        log.info(f"[FIXTURE] Created {obj}")

        if enable_sync:
            operation = server.operations.new("NuxeoDrive.SetSynchronization")
            operation.params = {"enable": True}
            operation.input_obj = obj.path
            operation.execute()

        return obj
Exemple #3
0
def test_ctx_menu_entries(nuxeo_url, exe, server, tmp):
    """Will test:
        - access-online
        - copy-share-link
        - edit-metadata
    """

    folder = tmp()
    assert not folder.is_dir()
    local_folder = f'--local-folder="{str(folder)}"'

    ws = None

    try:
        # 1st, bind the server
        args = f"Administrator {nuxeo_url} {local_folder} --password Administrator"
        assert bind(exe, args)
        assert folder.is_dir()

        # 2nd, create a workspace
        new = Document(
            name="my workspace",
            type="Workspace",
            properties={"dc:title": "my workspace"},
        )
        ws = server.documents.create(new, parent_path=env.WS_DIR)

        # 3rd, bind the root (e.g.: enable the sync of the workspace)
        args = f'bind-root "{ws.path}" {local_folder}'
        assert launch(exe, args, wait=5)

        # 4th, sync and quit
        assert launch(exe, "console --sync-and-quit", wait=40)

        # Check
        synced_folder = folder / ws.title
        assert (synced_folder).is_dir()

        # Get the copy-share link
        args = f'copy-share-link --file="{str(synced_folder)}"'
        assert launch(exe, args)
        url_copied = cb_get()
        assert url_copied.startswith(nuxeo_url)
        assert url_copied.endswith(ws.uid)

        # Test access-online, it should open a browser
        args = f'access-online --file="{str(synced_folder)}"'
        assert launch(exe, args)
        # assert get_opened_url() == url_copied

        # Test edit-metadata, it should open a browser
        args = f'edit-metadata --file="{str(synced_folder)}"'
        assert launch(exe, args)
        # assert get_opened_url() == url_copied
    finally:
        if ws:
            ws.delete()

        assert launch(exe, f"clean-folder {local_folder}")

        os.chmod(folder, stat.S_IWUSR)
        shutil.rmtree(folder)
        assert not os.path.isdir(folder)