2018-10-30 17:46:37 +00:00
|
|
|
import io
|
|
|
|
from PyQt5 import QtCore
|
|
|
|
|
2018-11-03 08:55:38 +00:00
|
|
|
import vorta.borg.borg_thread
|
2018-10-30 17:46:37 +00:00
|
|
|
import vorta.models
|
|
|
|
from vorta.views.repo_add import AddRepoWindow
|
2018-10-31 11:14:12 +00:00
|
|
|
from vorta.models import EventLogModel, RepoModel
|
2018-10-30 17:46:37 +00:00
|
|
|
|
2018-11-03 08:55:38 +00:00
|
|
|
def test_repo_tab(app, qtbot):
|
|
|
|
main = app.main_window
|
2018-10-30 17:46:37 +00:00
|
|
|
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-10-30 17:46:37 +00:00
|
|
|
|
|
|
|
|
2018-11-03 08:55:38 +00:00
|
|
|
def test_repo_add(app, qtbot, mocker):
|
2018-10-30 17:46:37 +00:00
|
|
|
# Add new repo window
|
2018-11-03 08:55:38 +00:00
|
|
|
main = app.main_window
|
|
|
|
add_repo_window = AddRepoWindow(main.repoTab)
|
2018-10-30 17:46:37 +00:00
|
|
|
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')
|
|
|
|
|
|
|
|
popen_result =mocker.MagicMock(stdout=io.StringIO("some initial binary data"),
|
|
|
|
stderr=io.StringIO("some initial binary data"),
|
|
|
|
returncode=0)
|
2018-11-03 08:55:38 +00:00
|
|
|
mocker.patch.object(vorta.borg.borg_thread, 'Popen', return_value=popen_result)
|
2018-10-30 17:46:37 +00:00
|
|
|
|
|
|
|
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])
|
|
|
|
|
2018-11-04 15:37:46 +00:00
|
|
|
# assert EventLogModel.select().count() == 2
|
2018-10-30 17:46:37 +00:00
|
|
|
assert RepoModel.get(id=1).url == 'aaabbb.com:repo'
|
2018-11-03 08:55:38 +00:00
|
|
|
|