diff --git a/tests/unit/test_misc.py b/tests/unit/test_misc.py index 634ebf098..4be9ff832 100644 --- a/tests/unit/test_misc.py +++ b/tests/unit/test_misc.py @@ -6,6 +6,7 @@ import pytest import vorta.store.models from PyQt6 import QtCore +from PyQt6.QtGui import QCloseEvent from PyQt6.QtWidgets import QCheckBox, QFormLayout from vorta.store.models import SettingsModel @@ -53,6 +54,23 @@ def test_autostart_linux(qapp, qtbot): assert not os.path.exists(autostart_path) +def test_enable_background_question(qapp, monkeypatch, mocker): + main = qapp.main_window + close_event = Mock(value=QCloseEvent()) + + # disable system trey and enable setting to test + monkeypatch.setattr("vorta.views.main_window.is_system_tray_available", lambda: False) + mocker.patch.object(vorta.store.models.SettingsModel, "get", return_value=Mock(value=True)) + + # users should be prompted whether to run Vorta in background + mock_msgbox = mocker.patch("vorta.views.main_window.QMessageBox", autospec=True) + main.closeEvent(close_event) + + mock_msgbox.assert_called_once() + mock_msgbox().setText.assert_called_with("Should Vorta continue to run in the background?") + close_event.accept.assert_called_once() + + def test_enable_fixed_units(qapp, qtbot, mocker): """Tests the 'enable fixed units' setting to ensure the archive tab sizes are displayed correctly.""" tab = qapp.main_window.archiveTab