mirror of https://gitlab.com/openlp/openlp.git
Merge branch 'more-non-linux-test-fixes' into 'master'
Fix more non-linux test See merge request openlp/openlp!718
This commit is contained in:
commit
77627f55f0
|
@ -51,7 +51,7 @@ test_script:
|
||||||
cd $env:APPVEYOR_BUILD_FOLDER
|
cd $env:APPVEYOR_BUILD_FOLDER
|
||||||
# Run the tests
|
# Run the tests
|
||||||
python -m pytest tests
|
python -m pytest tests
|
||||||
if ($? -eq $False) {
|
if ($LastExitCode -ne 0) {
|
||||||
throw "The tests failed!"
|
throw "The tests failed!"
|
||||||
}
|
}
|
||||||
# Go back to the user root folder
|
# Go back to the user root folder
|
||||||
|
|
|
@ -266,7 +266,7 @@ class PathEdit(QtWidgets.QWidget):
|
||||||
"""
|
"""
|
||||||
if path:
|
if path:
|
||||||
self._path = Path(path)
|
self._path = Path(path)
|
||||||
text = path_to_str(path)
|
text = path_to_str(self._path)
|
||||||
self.line_edit.setText(text)
|
self.line_edit.setText(text)
|
||||||
self.line_edit.setToolTip(text)
|
self.line_edit.setToolTip(text)
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,12 @@ ip6_link_local = 'fe80::223:14ff:fe99:d315'
|
||||||
ip6_bad = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
|
ip6_bad = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
|
||||||
|
|
||||||
|
|
||||||
|
if is_win():
|
||||||
|
p_prefix = 'C:\\'
|
||||||
|
else:
|
||||||
|
p_prefix = '/'
|
||||||
|
|
||||||
|
|
||||||
def test_extension_loader_no_files_found():
|
def test_extension_loader_no_files_found():
|
||||||
"""
|
"""
|
||||||
Test the `extension_loader` function when no files are found
|
Test the `extension_loader` function when no files are found
|
||||||
|
@ -91,12 +97,6 @@ def test_extension_loader_files_found():
|
||||||
assert "/app/dir/community" not in sys.path, "Community path has been added to the application sys.path"
|
assert "/app/dir/community" not in sys.path, "Community path has been added to the application sys.path"
|
||||||
|
|
||||||
|
|
||||||
if is_win():
|
|
||||||
p_prefix = 'C:\\'
|
|
||||||
else:
|
|
||||||
p_prefix = '/'
|
|
||||||
|
|
||||||
|
|
||||||
def test_extension_loader_files_found_community():
|
def test_extension_loader_files_found_community():
|
||||||
"""
|
"""
|
||||||
Test the `extension_loader` function when it successfully finds and loads some files
|
Test the `extension_loader` function when it successfully finds and loads some files
|
||||||
|
@ -130,7 +130,7 @@ def test_extension_loader_import_error():
|
||||||
with patch('openlp.core.common.applocation.AppLocation.get_directory',
|
with patch('openlp.core.common.applocation.AppLocation.get_directory',
|
||||||
return_value=Path(p_prefix, 'app', 'dir', 'openlp')), \
|
return_value=Path(p_prefix, 'app', 'dir', 'openlp')), \
|
||||||
patch.object(Path, 'glob', return_value=[
|
patch.object(Path, 'glob', return_value=[
|
||||||
Path('/', 'app', 'dir', 'openlp', 'import_dir', 'file1.py')]), \
|
Path(p_prefix, 'app', 'dir', 'openlp', 'import_dir', 'file1.py')]), \
|
||||||
patch('openlp.core.common.import_openlp_module', side_effect=ImportError()), \
|
patch('openlp.core.common.import_openlp_module', side_effect=ImportError()), \
|
||||||
patch('openlp.core.common.log') as mocked_logger:
|
patch('openlp.core.common.log') as mocked_logger:
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ def app_main_env():
|
||||||
openlp_server.is_another_instance_running.return_value = False
|
openlp_server.is_another_instance_running.return_value = False
|
||||||
mock_apploc.get_data_path.return_value = Path()
|
mock_apploc.get_data_path.return_value = Path()
|
||||||
mock_apploc.get_directory.return_value = Path()
|
mock_apploc.get_directory.return_value = Path()
|
||||||
mock_qapp.devicePixelRatio.return_value = 1.0
|
mock_qapp.return_value.devicePixelRatio.return_value = 1.0
|
||||||
mock_warn.return_value = True
|
mock_warn.return_value = True
|
||||||
openlp_instance = MagicMock()
|
openlp_instance = MagicMock()
|
||||||
mock_openlp.return_value = openlp_instance
|
mock_openlp.return_value = openlp_instance
|
||||||
|
@ -344,6 +344,7 @@ def test_main_future_settings(mock_move: MagicMock, mock_get_path: MagicMock, mo
|
||||||
settings.from_future = MagicMock(return_value=True)
|
settings.from_future = MagicMock(return_value=True)
|
||||||
settings.version_mismatched = MagicMock(return_value=True)
|
settings.version_mismatched = MagicMock(return_value=True)
|
||||||
settings.clear = MagicMock()
|
settings.clear = MagicMock()
|
||||||
|
settings.upgrade_settings = MagicMock()
|
||||||
settings.setValue('core/application version', '3.0.1')
|
settings.setValue('core/application version', '3.0.1')
|
||||||
mock_warn.return_value = QtWidgets.QMessageBox.Yes
|
mock_warn.return_value = QtWidgets.QMessageBox.Yes
|
||||||
MOCKED_VERSION = {
|
MOCKED_VERSION = {
|
||||||
|
@ -362,6 +363,7 @@ def test_main_future_settings(mock_move: MagicMock, mock_get_path: MagicMock, mo
|
||||||
assert result is True
|
assert result is True
|
||||||
mock_move.assert_called_once()
|
mock_move.assert_called_once()
|
||||||
settings.clear.assert_called_once_with()
|
settings.clear.assert_called_once_with()
|
||||||
|
settings.upgrade_settings.assert_called_once_with()
|
||||||
mock_warn.assert_called_once()
|
mock_warn.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,7 @@ def main_window_reduced(settings, state):
|
||||||
# Mock classes and methods used by mainwindow.
|
# Mock classes and methods used by mainwindow.
|
||||||
with patch('openlp.core.ui.mainwindow.SettingsForm'), \
|
with patch('openlp.core.ui.mainwindow.SettingsForm'), \
|
||||||
patch('openlp.core.ui.mainwindow.OpenLPDockWidget'), \
|
patch('openlp.core.ui.mainwindow.OpenLPDockWidget'), \
|
||||||
|
patch('openlp.core.ui.mainwindow.QtCore.QTimer.singleShot'), \
|
||||||
patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox'), \
|
patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox'), \
|
||||||
patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget'), \
|
patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget'), \
|
||||||
patch('openlp.core.ui.mainwindow.ServiceManager'), \
|
patch('openlp.core.ui.mainwindow.ServiceManager'), \
|
||||||
|
@ -757,8 +758,10 @@ def test_load_settings_view_mode_live(mocked_view_mode, main_window, settings):
|
||||||
mocked_view_mode.assert_called_with(True, True, True, True, False, True)
|
mocked_view_mode.assert_called_with(True, True, True, True, False, True)
|
||||||
|
|
||||||
|
|
||||||
|
@patch('openlp.core.ui.mainwindow.QtCore.QTimer.singleShot')
|
||||||
@patch('openlp.core.ui.mainwindow.QtWidgets.QMessageBox.information')
|
@patch('openlp.core.ui.mainwindow.QtWidgets.QMessageBox.information')
|
||||||
def test_screen_changed_modal(mocked_information: MagicMock, main_window: MainWindow):
|
def test_screen_changed_modal(mocked_information: MagicMock, mocked_timer_singleshot: MagicMock,
|
||||||
|
main_window: MainWindow):
|
||||||
"""
|
"""
|
||||||
Test that the screen changed modal is shown whether a 'config_screen_changed' event is dispatched
|
Test that the screen changed modal is shown whether a 'config_screen_changed' event is dispatched
|
||||||
"""
|
"""
|
||||||
|
@ -774,8 +777,10 @@ def test_screen_changed_modal(mocked_information: MagicMock, main_window: MainWi
|
||||||
mocked_information.assert_called_once()
|
mocked_information.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
@patch('openlp.core.ui.mainwindow.QtCore.QTimer.singleShot')
|
||||||
@patch('openlp.core.ui.mainwindow.QtWidgets.QMessageBox.information')
|
@patch('openlp.core.ui.mainwindow.QtWidgets.QMessageBox.information')
|
||||||
def test_screen_changed_modal_sets_timestamp_after_blocking_on_modal(mocked_information: MagicMock,
|
def test_screen_changed_modal_sets_timestamp_after_blocking_on_modal(mocked_information: MagicMock,
|
||||||
|
mocked_timer_singleshot: MagicMock,
|
||||||
main_window: MainWindow):
|
main_window: MainWindow):
|
||||||
"""
|
"""
|
||||||
Test that the screen changed modal latest shown timestamp is set after showing warning message, so
|
Test that the screen changed modal latest shown timestamp is set after showing warning message, so
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
"""
|
"""
|
||||||
This module contains tests for the openlp.core.widgets.edits module
|
This module contains tests for the openlp.core.widgets.edits module
|
||||||
"""
|
"""
|
||||||
import os
|
|
||||||
import pytest
|
import pytest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import MagicMock, PropertyMock, patch, call
|
from unittest.mock import MagicMock, PropertyMock, patch, call
|
||||||
|
@ -29,6 +28,7 @@ from typing import Any
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtTest, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtTest, QtWidgets
|
||||||
|
|
||||||
|
from openlp.core.common.path import path_to_str
|
||||||
from openlp.core.common.platform import is_win
|
from openlp.core.common.platform import is_win
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
from openlp.core.widgets.dialogs import FileDialog
|
from openlp.core.widgets.dialogs import FileDialog
|
||||||
|
@ -89,7 +89,7 @@ def test_path_getter(path_edit: PathEdit):
|
||||||
|
|
||||||
|
|
||||||
if is_win():
|
if is_win():
|
||||||
p_prefix = 'C:/'
|
p_prefix = 'C:\\'
|
||||||
else:
|
else:
|
||||||
p_prefix = ''
|
p_prefix = ''
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ def test_path_setter(prop: Any, expected: Any, path_edit: PathEdit):
|
||||||
# should have also been set.
|
# should have also been set.
|
||||||
if expected is not None:
|
if expected is not None:
|
||||||
assert path_edit._path == Path(*expected)
|
assert path_edit._path == Path(*expected)
|
||||||
os_normalised_str = os.path.join(*expected)
|
os_normalised_str = path_to_str(Path(*expected))
|
||||||
path_edit.line_edit.setToolTip.assert_called_once_with(os_normalised_str)
|
path_edit.line_edit.setToolTip.assert_called_once_with(os_normalised_str)
|
||||||
path_edit.line_edit.setText.assert_called_once_with(os_normalised_str)
|
path_edit.line_edit.setText.assert_called_once_with(os_normalised_str)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue