Пример #1
0
async def test_activity_mounting(ovshell: testing.OpenVarioShellStub) -> None:
    # GIVEN
    urwid_mock = UrwidMock()
    mountwatcher = AutomountWatcherStub()
    rsync = RsyncRunnerStub()
    backupdir = BackupDirectoryStub()
    act = BackupRestoreMainActivity(ovshell, mountwatcher, rsync, backupdir)
    w = act.create()
    act.activate()
    act.show()

    await asyncio.sleep(0)
    assert "Please insert USB storage" in urwid_mock.render(w)

    # WHEN
    mountwatcher.stub_mount()
    await asyncio.sleep(0)

    # THEN
    assert "This app allows to copy files to and from USB stick" in urwid_mock.render(w)
    assert "No files to restore." in urwid_mock.render(w)

    # WHEN
    backupdir.backed_up_files = ["file_one", "file_two"]
    act.show()
    assert "file_one" in urwid_mock.render(w)
    assert "file_two" in urwid_mock.render(w)
Пример #2
0
async def test_activity_backup(ovshell: testing.OpenVarioShellStub) -> None:
    # GIVEN
    urwid_mock = UrwidMock()
    mountwatcher = AutomountWatcherStub()
    rsync = RsyncRunnerStub()
    backupdir = BackupDirectoryStub()
    act = BackupRestoreMainActivity(ovshell, mountwatcher, rsync, backupdir)
    w = act.create()
    act.activate()
    mountwatcher.stub_mount()

    # WHEN
    # Press the default button (Backup)
    assert "Backup" in urwid_mock.render(w)
    urwid_mock.keypress(w, ["enter"])

    # THEN
    pact = ovshell.screen.stub_top_activity()
    assert isinstance(pact, BackupActivity)