mirror of
https://github.com/borgbase/vorta
synced 2024-12-23 00:07:58 +00:00
b015368fee
Move existing tests into subfolder `tests/unit`. Write integration tests that actually run the installed borg executable. Those tests can be found in `tests/integration`. Those pytest fixtures that are the same for both kinds of tests remain in `tests/conftest.py`. The others can be found in `tests/integration/conftest.py` or `tests/unit/conftest.py`. This adds nox to the project and configures it to run the tests with different borg versions. This also updates the ci workflow to run the integration tests using nox. * noxfile.py : Run pytest with a matrix of borg versions OR a specific borg version * Makefile : Run using nox. Add phonies `test-unit` and `test-integration`. * tests/conftest.py : Move some fixtures/functions to `tests/unit/conftest.py`. * tests/test_*.py --> tests/unit/ : Move unittests and assets into subfolder * tests/integration/ : Write integration tests. * requirements.d/dev.txt: Add `nox` and `pkgconfig`. The latter is needed for installing new borg versions. * .github/actions/setup/action.yml : Update to install pre-commit and nox when needed. The action now no longer installs Vorta. * .github/actions/install-dependencies/action.yml : Install system deps of borg with this new composite action. * .github/workflows/test.yml : Rename `test` ci to `test-unit` and update it for the new test setup. Implement `test-integration` ci. Signed-off-by: Chirag Aggarwal <thechiragaggarwal@gmail.com>
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
import pytest
|
|
import vorta.application
|
|
import vorta.borg.borg_job
|
|
from PyQt6 import QtCore
|
|
|
|
|
|
def test_create_perm_error(qapp, borg_json_output, mocker, qtbot):
|
|
main = qapp.main_window
|
|
mocker.patch.object(vorta.application.QMessageBox, 'show')
|
|
|
|
stdout, stderr = borg_json_output('create_perm')
|
|
popen_result = mocker.MagicMock(stdout=stdout, stderr=stderr, returncode=0)
|
|
mocker.patch.object(vorta.borg.borg_job, 'Popen', return_value=popen_result)
|
|
|
|
qtbot.mouseClick(main.createStartBtn, QtCore.Qt.MouseButton.LeftButton)
|
|
|
|
qtbot.waitUntil(lambda: hasattr(qapp, '_msg'), **pytest._wait_defaults)
|
|
assert qapp._msg.text().startswith("You do not have permission")
|
|
del qapp._msg
|
|
|
|
|
|
def test_create_lock(qapp, borg_json_output, mocker, qtbot):
|
|
main = qapp.main_window
|
|
mocker.patch.object(vorta.application.QMessageBox, 'show')
|
|
|
|
# Trigger locked repo
|
|
stdout, stderr = borg_json_output('create_lock')
|
|
popen_result = mocker.MagicMock(stdout=stdout, stderr=stderr, returncode=0)
|
|
mocker.patch.object(vorta.borg.borg_job, 'Popen', return_value=popen_result)
|
|
|
|
qtbot.mouseClick(main.createStartBtn, QtCore.Qt.MouseButton.LeftButton)
|
|
|
|
qtbot.waitUntil(lambda: hasattr(qapp, '_msg'), **pytest._wait_defaults)
|
|
assert "The repository at" in qapp._msg.text()
|
|
|
|
# Break locked repo
|
|
stdout, stderr = borg_json_output('create_break')
|
|
popen_result = mocker.MagicMock(stdout=stdout, stderr=stderr, returncode=0)
|
|
mocker.patch.object(vorta.borg.borg_job, 'Popen', return_value=popen_result)
|
|
|
|
qtbot.waitUntil(lambda: main.createStartBtn.isEnabled(), **pytest._wait_defaults) # Prevent thread collision
|
|
qapp._msg.accept()
|
|
exp_message_text = 'Repository lock broken. Please redo your last action.'
|
|
qtbot.waitUntil(lambda: exp_message_text in main.progressText.text(), **pytest._wait_defaults)
|