Ejemplo n.º 1
0
async def test_workspace_button_owned_by(qtbot, workspace_fs, core_config, bob,
                                         alice_user_info, bob_user_info):
    switch_language(core_config, "en")

    roles = {
        bob.user_id: (WorkspaceRole.OWNER, bob_user_info),
        alice_user_info.user_id: (WorkspaceRole.READER, alice_user_info),
    }
    w = WorkspaceButton.create(
        workspace_name=EntryName("Workspace"),
        workspace_fs=workspace_fs,
        users_roles=roles,
        is_mounted=True,
        files=[],
    )

    qtbot.add_widget(w)
    w.show()
    assert w.widget_empty.isVisible() is True
    assert w.widget_files.isVisible() is False
    assert w.label_owner.isVisible() is False
    assert w.label_shared.isVisible() is True
    assert w.name == EntryName("Workspace")
    assert w.label_title.text().startswith("Workspace")
    assert w.label_title.toolTip() == "Workspace (owned by Boby McBobFace)"
    assert w.label_role.text() == _("TEXT_WORKSPACE_ROLE_READER")
Ejemplo n.º 2
0
async def test_workspace_button_reencrypt_clicked(qtbot, workspace_fs,
                                                  core_config,
                                                  alice_user_info):
    switch_language(core_config, "en")

    roles = {
        workspace_fs.device.user_id: (WorkspaceRole.OWNER, alice_user_info)
    }
    w = WorkspaceButton.create(
        workspace_name=EntryName("Workspace"),
        workspace_fs=workspace_fs,
        users_roles=roles,
        is_mounted=True,
        files=[],
    )
    w.reencryption_needs = ReencryptionNeed(
        user_revoked=True,
        role_revoked=False,
        reencryption_already_in_progress=False)

    qtbot.add_widget(w)

    assert not w.button_reencrypt.isHidden()

    w.reencrypting = (8, 4)
    assert w.widget_actions.isHidden()
    assert not w.widget_reencryption.isHidden()
    assert w.progress_reencryption.value() == 50
    assert w.progress_reencryption.text() == "Reencrypting... 50%"

    w.reencrypting = None
    assert not w.widget_actions.isHidden()
    assert w.widget_reencryption.isHidden()
Ejemplo n.º 3
0
async def test_workspace_button_files(qtbot, workspace_fs, core_config,
                                      alice_user_info):
    switch_language(core_config, "en")

    roles = {alice_user_info.user_id: (WorkspaceRole.OWNER, alice_user_info)}
    w = WorkspaceButton.create(
        workspace_name=EntryName("Workspace"),
        workspace_fs=workspace_fs,
        users_roles=roles,
        is_mounted=True,
        files=[
            EntryName("File1.txt"),
            EntryName("File2.txt"),
            EntryName("Dir1")
        ],
    )

    qtbot.add_widget(w)
    w.show()
    assert w.widget_empty.isVisible() is False
    assert w.widget_files.isVisible() is True
    assert w.label_owner.isVisible() is True
    assert w.label_shared.isVisible() is False
    assert w.name == EntryName("Workspace")
    assert w.file1_name.text() == "File1.txt"
    assert w.file2_name.text() == "File2.txt"
    assert w.file3_name.text() == "Dir1"
    assert w.file4_name.text() == ""
Ejemplo n.º 4
0
async def test_workspace_button_timestamped(qtbot, workspace_fs, core_config,
                                            alice_user_info):
    switch_language(core_config, "en")
    timestamp = pendulum.now().add(seconds=10)
    roles = {alice_user_info.user_id: (WorkspaceRole.OWNER, alice_user_info)}
    ts_workspace_fs = WorkspaceFSTimestamped(workspace_fs, timestamp)
    w = WorkspaceButton.create(
        workspace_name=EntryName("Workspace"),
        workspace_fs=ts_workspace_fs,
        users_roles=roles,
        is_mounted=True,
        timestamped=True,
    )
    assert w.timestamp == timestamp
    label = w.widget_empty.layout().itemAt(0).widget().label_timestamp
    assert label.text() == format_datetime(timestamp)
Ejemplo n.º 5
0
async def test_workspace_button_delete_clicked(qtbot, workspace_fs,
                                               core_config, alice_user_info):
    switch_language(core_config, "en")

    roles = {alice_user_info.user_id: (WorkspaceRole.OWNER, alice_user_info)}
    w = WorkspaceButton.create(
        workspace_name=EntryName("Workspace"),
        workspace_fs=workspace_fs,
        users_roles=roles,
        is_mounted=True,
        files=[],
    )
    qtbot.add_widget(w)
    with qtbot.waitSignal(w.delete_clicked, timeout=500) as blocker:
        qtbot.mouseClick(w.button_delete, QtCore.Qt.LeftButton)
    assert blocker.args == [workspace_fs]
async def test_workspace_button(qtbot, workspace_fs, core_config,
                                alice_user_info):
    switch_language(core_config, "en")

    roles = {alice_user_info.user_id: (WorkspaceRole.OWNER, alice_user_info)}
    w = WorkspaceButton.create(
        workspace_name="Workspace",
        workspace_fs=workspace_fs,
        users_roles=roles,
        is_mounted=True,
        files=[],
    )
    qtbot.addWidget(w)
    w.show()

    assert w.widget_empty.isVisible() is True
    assert w.widget_files.isVisible() is False
    assert w.label_owner.isVisible() is True
    assert w.label_shared.isVisible() is False
    assert w.name == "Workspace"
    assert w.label_title.text().startswith("Workspace")
    assert w.label_title.toolTip() == "Workspace (private)"
    assert w.label_role.text() == _("TEXT_WORKSPACE_ROLE_OWNER")