1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-23 16:26:55 +00:00
vorta/tests/test_repo.py

62 lines
2.5 KiB
Python
Raw Normal View History

from PyQt5 import QtCore
import vorta.borg.borg_thread
import vorta.models
from vorta.views.repo_add import AddRepoWindow
2018-11-06 06:47:04 +00:00
from vorta.models import EventLogModel, RepoModel, SnapshotModel
2018-11-06 06:47:04 +00:00
def test_create_error(app, qtbot):
main = app.main_window
qtbot.mouseClick(main.createStartBtn, QtCore.Qt.LeftButton)
2018-10-31 11:14:12 +00:00
assert main.createProgressText.text() == 'Add a remote backup repository first.'
2018-11-06 06:47:04 +00:00
def test_repo_add(app, qtbot, mocker, borg_json_output):
# Add new repo window
main = app.main_window
add_repo_window = AddRepoWindow(main.repoTab)
qtbot.keyClicks(add_repo_window.repoURL, 'aaa')
qtbot.mouseClick(add_repo_window.saveButton, QtCore.Qt.LeftButton)
assert add_repo_window.errorText.text() == 'Please enter a valid repo URL including hostname and path.'
qtbot.keyClicks(add_repo_window.repoURL, 'bbb.com:repo')
qtbot.mouseClick(add_repo_window.saveButton, QtCore.Qt.LeftButton)
assert add_repo_window.errorText.text() == 'Please use a longer password.'
qtbot.keyClicks(add_repo_window.passwordLineEdit, 'long-password-long')
2018-11-06 06:47:04 +00:00
stdout, stderr = borg_json_output('info')
popen_result =mocker.MagicMock(stdout=stdout,
stderr=stderr,
returncode=0)
mocker.patch.object(vorta.borg.borg_thread, 'Popen', return_value=popen_result)
qtbot.mouseClick(add_repo_window.saveButton, QtCore.Qt.LeftButton)
with qtbot.waitSignal(add_repo_window.thread.result, timeout=1000) as blocker:
pass
main.repoTab.process_new_repo(blocker.args[0])
# assert EventLogModel.select().count() == 2
assert RepoModel.get(id=1).url == 'aaabbb.com:repo'
2018-11-06 06:47:04 +00:00
def test_create(app_with_repo, borg_json_output, mocker, qtbot):
main = app_with_repo.main_window
stdout, stderr = borg_json_output('create')
popen_result =mocker.MagicMock(stdout=stdout,
stderr=stderr,
returncode=0)
mocker.patch.object(vorta.borg.borg_thread, 'Popen', return_value=popen_result)
qtbot.mouseClick(main.createStartBtn, QtCore.Qt.LeftButton)
qtbot.waitUntil(lambda: main.createProgressText.text().startswith('INFO: Remote'))
assert EventLogModel.select().count() == 1
assert SnapshotModel.select().count() == 1
assert RepoModel.get(id=1).unique_size == 15520474
assert main.createStartBtn.isEnabled()
assert main.snapshotTab.snapshotTable.rowCount() == 1
assert main.scheduleTab.logTableWidget.rowCount() == 1