diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 0a0de0b24..3f1ee9c1b 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -135,6 +135,7 @@ class BibleImportForm(OpenLPWizard): Add the bible import specific wizard pages. """ # Select Page + self.spacers = [] self.select_page = QtWidgets.QWizardPage() self.select_page.setObjectName('SelectPage') self.select_page_layout = QtWidgets.QVBoxLayout(self.select_page) @@ -147,8 +148,8 @@ class BibleImportForm(OpenLPWizard): self.format_combo_box.addItems(['', '', '', '', '', '', '']) self.format_combo_box.setObjectName('FormatComboBox') self.format_layout.addRow(self.format_label, self.format_combo_box) - self.spacer = QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) - self.format_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) + self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) + self.format_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) self.select_page_layout.addLayout(self.format_layout) self.select_stack = QtWidgets.QStackedLayout() self.select_stack.setObjectName('SelectStack') @@ -170,7 +171,8 @@ class BibleImportForm(OpenLPWizard): self.osis_browse_button.setObjectName('OsisBrowseButton') self.osis_file_layout.addWidget(self.osis_browse_button) self.osis_layout.addRow(self.osis_file_label, self.osis_file_layout) - self.osis_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) + self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) + self.osis_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) self.select_stack.addWidget(self.osis_widget) self.csv_widget = QtWidgets.QWidget(self.select_page) self.csv_widget.setObjectName('CsvWidget') @@ -203,7 +205,8 @@ class BibleImportForm(OpenLPWizard): self.csv_verses_button.setObjectName('CsvVersesButton') self.csv_verses_layout.addWidget(self.csv_verses_button) self.csv_layout.addRow(self.csv_verses_label, self.csv_verses_layout) - self.csv_layout.setItem(3, QtWidgets.QFormLayout.LabelRole, self.spacer) + self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) + self.csv_layout.setItem(2, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) self.select_stack.addWidget(self.csv_widget) self.open_song_widget = QtWidgets.QWidget(self.select_page) self.open_song_widget.setObjectName('OpenSongWidget') @@ -223,7 +226,8 @@ class BibleImportForm(OpenLPWizard): self.open_song_browse_button.setObjectName('OpenSongBrowseButton') self.open_song_file_layout.addWidget(self.open_song_browse_button) self.open_song_layout.addRow(self.open_song_file_label, self.open_song_file_layout) - self.open_song_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) + self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) + self.open_song_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) self.select_stack.addWidget(self.open_song_widget) self.web_tab_widget = QtWidgets.QTabWidget(self.select_page) self.web_tab_widget.setObjectName('WebTabWidget') @@ -300,7 +304,8 @@ class BibleImportForm(OpenLPWizard): self.zefania_browse_button.setObjectName('ZefaniaBrowseButton') self.zefania_file_layout.addWidget(self.zefania_browse_button) self.zefania_layout.addRow(self.zefania_file_label, self.zefania_file_layout) - self.zefania_layout.setItem(5, QtWidgets.QFormLayout.LabelRole, self.spacer) + self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) + self.zefania_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) self.select_stack.addWidget(self.zefania_widget) self.sword_widget = QtWidgets.QWidget(self.select_page) self.sword_widget.setObjectName('SwordWidget') @@ -381,7 +386,8 @@ class BibleImportForm(OpenLPWizard): self.wordproject_browse_button.setObjectName('WordProjectBrowseButton') self.wordproject_file_layout.addWidget(self.wordproject_browse_button) self.wordproject_layout.addRow(self.wordproject_file_label, self.wordproject_file_layout) - self.wordproject_layout.setItem(5, QtWidgets.QFormLayout.LabelRole, self.spacer) + self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) + self.wordproject_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) self.select_stack.addWidget(self.wordproject_widget) self.select_page_layout.addLayout(self.select_stack) self.addPage(self.select_page) @@ -499,7 +505,8 @@ class BibleImportForm(OpenLPWizard): self.csv_verses_label.minimumSizeHint().width(), self.open_song_file_label.minimumSizeHint().width(), self.zefania_file_label.minimumSizeHint().width()) - self.spacer.changeSize(label_width, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) + for spacer in self.spacers: + spacer.changeSize(label_width, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) def validateCurrentPage(self): """ diff --git a/scripts/appveyor-webhook.py b/scripts/appveyor-webhook.py index fc844e265..630c404d7 100755 --- a/scripts/appveyor-webhook.py +++ b/scripts/appveyor-webhook.py @@ -35,8 +35,9 @@ import sys import time from subprocess import Popen, PIPE -appveyor_build_url = 'https://ci.appveyor.com/project/TomasGroth/openlp/build' -appveyor_api_url = 'https://ci.appveyor.com/api/projects/TomasGroth/openlp' +appveyor_build_url = 'https://ci.appveyor.com/project/OpenLP/{project}/build' +appveyor_api_url = 'https://ci.appveyor.com/api/projects/OpenLP/{project}' +appveyor_log_url = 'https://ci.appveyor.com/api/buildjobs/{buildid}/log' webhook_element = \ { @@ -84,7 +85,7 @@ def get_version(): return version_string, version -def get_yml(branch): +def get_yml(branch, build_type): """ Returns the content of appveyor.yml and inserts the branch to be build """ @@ -92,7 +93,7 @@ def get_yml(branch): yml_text = f.read() f.close() yml_text = yml_text.replace('BRANCHNAME', branch) - if 'openlp-core/openlp/trunk' in branch: + if build_type in ['openlp', 'trunk']: yml_text = yml_text.replace('BUILD_DOCS', '$TRUE') else: yml_text = yml_text.replace('BUILD_DOCS', '$FALSE') @@ -115,23 +116,28 @@ def hook(webhook_url, yml): print(responce.read().decode('utf-8')) -def get_appveyor_build_url(branch): +def get_appveyor_build_url(build_type): """ Get the url of the build. """ - responce = urllib.request.urlopen(appveyor_api_url) + responce = urllib.request.urlopen(appveyor_api_url.format(project=build_type)) json_str = responce.read().decode('utf-8') build_json = json.loads(json_str) - build_url = '%s/%s' % (appveyor_build_url, build_json['build']['version']) - print('Check this URL for build status: %s' % build_url) + build_url = '%s/%s' % (appveyor_build_url.format(project=build_type), build_json['build']['version']) + print(build_url.format(project=build_type)) + print(appveyor_log_url.format(buildid=build_json['build']['jobs'][0]['jobId'])) -if len(sys.argv) != 3: - print('Usage: %s ' % sys.argv[0]) +if len(sys.argv) != 4: + print('Invalid number of arguments\nUsage: %s ' % sys.argv[0]) else: webhook_url = sys.argv[1] branch = sys.argv[2] - hook(webhook_url, get_yml(branch)) + build_type = sys.argv[3] + if build_type not in ['dev', 'trunk', 'openlp']: + print('Invalid build type\nUsage: %s ' % sys.argv[0]) + exit() + hook(webhook_url, get_yml(branch, build_type)) # Wait 5 seconds to make sure the hook has been triggered time.sleep(5) - get_appveyor_build_url(branch) + get_appveyor_build_url(build_type) diff --git a/scripts/appveyor.yml b/scripts/appveyor.yml index 8b123e5a7..3d2ceda21 100644 --- a/scripts/appveyor.yml +++ b/scripts/appveyor.yml @@ -19,14 +19,14 @@ install: - "%PYTHON%\\python.exe -m pip install https://get.openlp.org/win-sdk/lxml-3.6.4-cp34-cp34m-win32.whl" - "%PYTHON%\\python.exe -m pip install https://get.openlp.org/win-sdk/PyICU-1.9.5-cp34-cp34m-win32.whl" # Download and install PyQt5 - - curl -L -O http://downloads.sourceforge.net/project/pyqt/PyQt5/PyQt-5.5.1/PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x32.exe + - appveyor DownloadFile http://downloads.sourceforge.net/project/pyqt/PyQt5/PyQt-5.5.1/PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x32.exe - PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x32.exe /S # Download and unpack mupdf - - curl -O http://mupdf.com/downloads/archive/mupdf-1.9a-windows.zip + - appveyor DownloadFile http://mupdf.com/downloads/archive/mupdf-1.9a-windows.zip - 7z x mupdf-1.9a-windows.zip - cp mupdf-1.9a-windows/mupdf.exe openlp-branch/mupdf.exe # Download and unpack mediainfo - - curl -O https://mediaarea.net/download/binary/mediainfo/0.7.90/MediaInfo_CLI_0.7.90_Windows_i386.zip + - appveyor DownloadFile https://mediaarea.net/download/binary/mediainfo/0.7.90/MediaInfo_CLI_0.7.90_Windows_i386.zip - mkdir MediaInfo - 7z x -oMediaInfo MediaInfo_CLI_0.7.90_Windows_i386.zip - cp MediaInfo\\MediaInfo.exe openlp-branch\\MediaInfo.exe @@ -43,15 +43,15 @@ test_script: after_test: # This is where we create a package using PyInstaller # First get PyInstaller - - curl -L -O https://github.com/pyinstaller/pyinstaller/releases/download/v3.2/PyInstaller-3.2.zip + - appveyor DownloadFile https://github.com/pyinstaller/pyinstaller/releases/download/v3.2/PyInstaller-3.2.zip - 7z x PyInstaller-3.2.zip # Install PyInstaller dependencies - "%PYTHON%\\python.exe -m pip install future pefile" # Download and install Inno Setup - used for packaging - - curl -L -O http://www.jrsoftware.org/download.php/is-unicode.exe + - appveyor DownloadFile http://www.jrsoftware.org/download.php/is-unicode.exe - is-unicode.exe /VERYSILENT /SUPPRESSMSGBOXES /SP- # Download and unpack portable-bundle - - curl -O https://get.openlp.org/win-sdk/portable-setup.7z + - appveyor DownloadFile https://get.openlp.org/win-sdk/portable-setup.7z - 7z x portable-setup.7z # Disabled portable installers - can't figure out how to make them silent # - curl -L -O http://downloads.sourceforge.net/project/portableapps/PortableApps.com%20Installer/PortableApps.comInstaller_3.4.4.paf.exe @@ -61,7 +61,7 @@ after_test: # - curl -L -O http://downloads.sourceforge.net/project/portableapps/NSIS%20Portable/NSISPortable_3.0_English.paf.exe # - NSISPortable_3.0_English.paf.exe /S # Get the packaging code - - curl -L http://bazaar.launchpad.net/~openlp-core/openlp/packaging/tarball -o packaging.tar.gz + - appveyor DownloadFile http://bazaar.launchpad.net/~openlp-core/openlp/packaging/tarball -FileName packaging.tar.gz - 7z e packaging.tar.gz - 7z x packaging.tar - mv ~openlp-core/openlp/packaging packaging @@ -74,7 +74,7 @@ after_test: 7z x documentation.tar mv ~openlp-core/openlp/documentation documentation cd packaging - &"$env:PYTHON\python.exe" builders/windows-builder.py --skip-update --skip-translations -c windows/config-appveyor.ini -b ../openlp-branch -d ../documentation --portable + &"$env:PYTHON\python.exe" builders/windows-builder.py --skip-update -c windows/config-appveyor.ini -b ../openlp-branch -d ../documentation --portable } else { cd packaging &"$env:PYTHON\python.exe" builders/windows-builder.py --skip-update --skip-translations -c windows/config-appveyor.ini -b ../openlp-branch --portable diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index c54d849b9..1684e6084 100755 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -59,14 +59,13 @@ class OpenLPJobs(object): Branch_Pull = 'Branch-01-Pull' Branch_Functional = 'Branch-02-Functional-Tests' Branch_Interface = 'Branch-03-Interface-Tests' - Branch_Windows_Functional = 'Branch-04a-Windows_Functional_Tests' - Branch_Windows_Interface = 'Branch-04b-Windows_Interface_Tests' - Branch_PEP = 'Branch-05a-Code_Analysis' - Branch_Coverage = 'Branch-05b-Test_Coverage' - Branch_Pylint = 'Branch-05c-Code_Analysis2' + Branch_PEP = 'Branch-04a-Code_Analysis' + Branch_Coverage = 'Branch-04b-Test_Coverage' + Branch_Pylint = 'Branch-04c-Code_Analysis2' + Branch_AppVeyor = 'Branch-05-AppVeyor-Tests' - Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows_Functional, Branch_Windows_Interface, - Branch_PEP, Branch_Coverage, Branch_Pylint] + Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_PEP, Branch_Coverage, Branch_Pylint, + Branch_AppVeyor] class Colour(object): diff --git a/tests/functional/__init__.py b/tests/functional/__init__.py index e9d536412..bb8d97f15 100644 --- a/tests/functional/__init__.py +++ b/tests/functional/__init__.py @@ -25,13 +25,8 @@ Base directory for tests import sys from PyQt5 import QtWidgets -if sys.version_info[1] >= 3: - from unittest.mock import ANY, MagicMock, patch, mock_open, call, PropertyMock -else: - from mock import ANY, MagicMock, patch, mock_open, call, PropertyMock - # Only one QApplication can be created. Use QtWidgets.QApplication.instance() when you need to "create" a QApplication. application = QtWidgets.QApplication([]) application.setApplicationName('OpenLP') -__all__ = ['ANY', 'MagicMock', 'patch', 'mock_open', 'call', 'application', 'PropertyMock'] +__all__ = ['application'] diff --git a/tests/functional/openlp_core_common/test_actions.py b/tests/functional/openlp_core_common/test_actions.py index 6ec78869e..1b28d9216 100644 --- a/tests/functional/openlp_core_common/test_actions.py +++ b/tests/functional/openlp_core_common/test_actions.py @@ -23,12 +23,13 @@ Package to test the openlp.core.common.actions package. """ from unittest import TestCase +from unittest.mock import MagicMock from PyQt5 import QtGui, QtCore, QtWidgets from openlp.core.common import Settings from openlp.core.common.actions import CategoryActionList, ActionList -from tests.functional import MagicMock + from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_core_common/test_applocation.py b/tests/functional/openlp_core_common/test_applocation.py index 28fbf6fba..bb8d58b9a 100644 --- a/tests/functional/openlp_core_common/test_applocation.py +++ b/tests/functional/openlp_core_common/test_applocation.py @@ -25,9 +25,9 @@ Functional tests to test the AppLocation class and related methods. import copy import os from unittest import TestCase +from unittest.mock import patch from openlp.core.common import AppLocation, get_frozen_path -from tests.functional import patch FILE_LIST = ['file1', 'file2', 'file3.txt', 'file4.txt', 'file5.mp3', 'file6.mp3'] diff --git a/tests/functional/openlp_core_common/test_common.py b/tests/functional/openlp_core_common/test_common.py index a2e03333a..7960fb7be 100644 --- a/tests/functional/openlp_core_common/test_common.py +++ b/tests/functional/openlp_core_common/test_common.py @@ -22,12 +22,11 @@ """ Functional tests to test the AppLocation class and related methods. """ - from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core.common import check_directory_exists, de_hump, trace_error_handler, translate, is_win, is_macosx, \ is_linux, clean_button_text -from tests.functional import MagicMock, patch class TestCommonFunctions(TestCase): diff --git a/tests/functional/openlp_core_common/test_httputils.py b/tests/functional/openlp_core_common/test_httputils.py index e99c925cf..c44f28198 100644 --- a/tests/functional/openlp_core_common/test_httputils.py +++ b/tests/functional/openlp_core_common/test_httputils.py @@ -26,10 +26,10 @@ import os import tempfile import socket from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core.common.httputils import get_user_agent, get_web_page, get_url_file_size, url_get_file -from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_core_common/test_init.py b/tests/functional/openlp_core_common/test_init.py index 1a87f0889..b3e49eacb 100644 --- a/tests/functional/openlp_core_common/test_init.py +++ b/tests/functional/openlp_core_common/test_init.py @@ -25,10 +25,11 @@ Functional tests to test the AppLocation class and related methods. import os from io import BytesIO from unittest import TestCase +from unittest.mock import MagicMock, PropertyMock, call, patch from openlp.core.common import add_actions, clean_filename, delete_file, get_file_encoding, get_filesystem_encoding, \ get_uno_command, get_uno_instance, split_filename -from tests.functional import MagicMock, PropertyMock, call, patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_core_common/test_languagemanager.py b/tests/functional/openlp_core_common/test_languagemanager.py index ccec091a7..48d45c7ce 100644 --- a/tests/functional/openlp_core_common/test_languagemanager.py +++ b/tests/functional/openlp_core_common/test_languagemanager.py @@ -23,8 +23,8 @@ Functional tests to test the AppLocation class and related methods. """ from unittest import TestCase +from unittest.mock import patch -from tests.functional import patch from openlp.core.common.languagemanager import get_locale_key, get_natural_key diff --git a/tests/functional/openlp_core_common/test_registry.py b/tests/functional/openlp_core_common/test_registry.py index aa4f0efb0..ad30efb73 100644 --- a/tests/functional/openlp_core_common/test_registry.py +++ b/tests/functional/openlp_core_common/test_registry.py @@ -24,9 +24,9 @@ Package to test the openlp.core.lib package. """ import os from unittest import TestCase +from unittest.mock import MagicMock from openlp.core.common import Registry -from tests.functional import MagicMock TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../', '..', 'resources')) diff --git a/tests/functional/openlp_core_common/test_registryproperties.py b/tests/functional/openlp_core_common/test_registryproperties.py index cbfaa9239..b38d829f6 100644 --- a/tests/functional/openlp_core_common/test_registryproperties.py +++ b/tests/functional/openlp_core_common/test_registryproperties.py @@ -23,11 +23,10 @@ Test the registry properties """ from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core.common import Registry, RegistryProperties -from tests.functional import MagicMock, patch - class TestRegistryProperties(TestCase, RegistryProperties): """ diff --git a/tests/functional/openlp_core_common/test_settings.py b/tests/functional/openlp_core_common/test_settings.py index a1c5ee6b3..6b30d0218 100644 --- a/tests/functional/openlp_core_common/test_settings.py +++ b/tests/functional/openlp_core_common/test_settings.py @@ -23,10 +23,11 @@ Package to test the openlp.core.lib.settings package. """ from unittest import TestCase +from unittest.mock import patch from openlp.core.common import Settings from openlp.core.common.settings import recent_files_conv -from tests.functional import patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_core_common/test_versionchecker.py b/tests/functional/openlp_core_common/test_versionchecker.py index 3f51e0018..022a5f06f 100644 --- a/tests/functional/openlp_core_common/test_versionchecker.py +++ b/tests/functional/openlp_core_common/test_versionchecker.py @@ -23,10 +23,11 @@ Package to test the openlp.core.common.versionchecker package. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core.common.settings import Settings from openlp.core.common.versionchecker import VersionThread -from tests.functional import MagicMock, patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_core_lib/test_db.py b/tests/functional/openlp_core_lib/test_db.py index 3d2c88200..70c6be9ae 100644 --- a/tests/functional/openlp_core_lib/test_db.py +++ b/tests/functional/openlp_core_lib/test_db.py @@ -24,13 +24,13 @@ Package to test the openlp.core.lib package. """ import os from unittest import TestCase +from unittest.mock import patch, MagicMock from sqlalchemy.pool import NullPool from sqlalchemy.orm.scoping import ScopedSession from sqlalchemy import MetaData from openlp.core.lib.db import init_db, get_upgrade_op, delete_database -from tests.functional import patch, MagicMock class TestDB(TestCase): diff --git a/tests/functional/openlp_core_lib/test_file_dialog.py b/tests/functional/openlp_core_lib/test_file_dialog.py index 238b398d3..488900fc7 100644 --- a/tests/functional/openlp_core_lib/test_file_dialog.py +++ b/tests/functional/openlp_core_lib/test_file_dialog.py @@ -1,11 +1,31 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2017 OpenLP Developers # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### """ Package to test the openlp.core.lib.filedialog package. """ from unittest import TestCase +from unittest.mock import MagicMock, call, patch -from openlp.core.common import UiStrings from openlp.core.lib.filedialog import FileDialog -from tests.functional import MagicMock, call, patch class TestFileDialog(TestCase): diff --git a/tests/functional/openlp_core_lib/test_formattingtags.py b/tests/functional/openlp_core_lib/test_formattingtags.py index e0e668e63..0787c67eb 100644 --- a/tests/functional/openlp_core_lib/test_formattingtags.py +++ b/tests/functional/openlp_core_lib/test_formattingtags.py @@ -24,10 +24,9 @@ Package to test the openlp.core.lib.formattingtags package. """ import copy from unittest import TestCase +from unittest.mock import patch from openlp.core.lib import FormattingTags -from tests.functional import patch - TAG = { 'end tag': '{/aa}', diff --git a/tests/functional/openlp_core_lib/test_htmlbuilder.py b/tests/functional/openlp_core_lib/test_htmlbuilder.py index 4bdbd363c..6e6806733 100644 --- a/tests/functional/openlp_core_lib/test_htmlbuilder.py +++ b/tests/functional/openlp_core_lib/test_htmlbuilder.py @@ -1,8 +1,8 @@ """ Package to test the openlp.core.lib.htmlbuilder module. """ - from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtCore, QtWebKit @@ -10,7 +10,7 @@ from openlp.core.common import Settings from openlp.core.lib.htmlbuilder import build_html, build_background_css, build_lyrics_css, build_lyrics_outline_css, \ build_lyrics_format_css, build_footer_css, webkit_version, build_chords_css from openlp.core.lib.theme import HorizontalType, VerticalType -from tests.functional import MagicMock, patch + from tests.helpers.testmixin import TestMixin HTML = """ diff --git a/tests/functional/openlp_core_lib/test_image_manager.py b/tests/functional/openlp_core_lib/test_image_manager.py index d2b9b4229..914c8607b 100644 --- a/tests/functional/openlp_core_lib/test_image_manager.py +++ b/tests/functional/openlp_core_lib/test_image_manager.py @@ -25,14 +25,15 @@ Package to test the openlp.core.ui package. import os import time from threading import Lock - from unittest import TestCase +from unittest.mock import patch + from PyQt5 import QtGui from openlp.core.common import Registry from openlp.core.lib import ImageManager, ScreenList from openlp.core.lib.imagemanager import Priority -from tests.functional import patch + from tests.helpers.testmixin import TestMixin TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources')) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 0f80df31d..3c7378dca 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -23,9 +23,9 @@ Package to test the openlp.core.lib package. """ import os - -from unittest import TestCase from datetime import datetime, timedelta +from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtCore, QtGui @@ -33,7 +33,6 @@ from openlp.core.lib import FormattingTags, expand_chords_for_printing from openlp.core.lib import build_icon, check_item_selected, clean_tags, create_thumb, create_separated_list, \ expand_tags, get_text_file_string, image_to_byte, resize_image, str_to_bool, validate_thumb, expand_chords, \ compare_chord_lyric, find_formatting_tags -from tests.functional import MagicMock, patch TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources')) diff --git a/tests/functional/openlp_core_lib/test_mediamanageritem.py b/tests/functional/openlp_core_lib/test_mediamanageritem.py index e6b18b753..fba8ce36b 100644 --- a/tests/functional/openlp_core_lib/test_mediamanageritem.py +++ b/tests/functional/openlp_core_lib/test_mediamanageritem.py @@ -23,10 +23,10 @@ Package to test the openlp.core.lib.mediamanageritem package. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core.lib import MediaManagerItem -from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_core_lib/test_pluginmanager.py b/tests/functional/openlp_core_lib/test_pluginmanager.py index 82a65c3fd..d829feccb 100644 --- a/tests/functional/openlp_core_lib/test_pluginmanager.py +++ b/tests/functional/openlp_core_lib/test_pluginmanager.py @@ -23,11 +23,11 @@ Package to test the openlp.core.lib.pluginmanager package. """ from unittest import TestCase +from unittest.mock import MagicMock from openlp.core.common import Registry, Settings from openlp.core.lib.pluginmanager import PluginManager from openlp.core.lib import PluginStatus -from tests.functional import MagicMock class TestPluginManager(TestCase): diff --git a/tests/functional/openlp_core_lib/test_projector_pjlink1.py b/tests/functional/openlp_core_lib/test_projector_pjlink1.py index 4482f6d22..16b73c377 100644 --- a/tests/functional/openlp_core_lib/test_projector_pjlink1.py +++ b/tests/functional/openlp_core_lib/test_projector_pjlink1.py @@ -22,14 +22,12 @@ """ Package to test the openlp.core.lib.projector.pjlink1 package. """ - from unittest import TestCase +from unittest.mock import patch, MagicMock from openlp.core.lib.projector.pjlink1 import PJLink1 -from openlp.core.lib.projector.constants import E_PARAMETER, ERROR_STRING, S_OFF, S_STANDBY, S_WARMUP, S_ON, \ - S_COOLDOWN, PJLINK_POWR_STATUS +from openlp.core.lib.projector.constants import E_PARAMETER, ERROR_STRING, S_OFF, S_STANDBY, S_ON, PJLINK_POWR_STATUS -from tests.functional import patch, MagicMock from tests.resources.projector.data import TEST_PIN, TEST_SALT, TEST_CONNECT_AUTHENTICATE, TEST_HASH pjlink_test = PJLink1(name='test', ip='127.0.0.1', pin=TEST_PIN, no_poll=True) diff --git a/tests/functional/openlp_core_lib/test_projectordb.py b/tests/functional/openlp_core_lib/test_projectordb.py index b81bb99bd..52b7f0d2f 100644 --- a/tests/functional/openlp_core_lib/test_projectordb.py +++ b/tests/functional/openlp_core_lib/test_projectordb.py @@ -27,11 +27,11 @@ PREREQUISITE: add_record() and get_all() functions validated. """ import os from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core.lib.projector.db import Manufacturer, Model, Projector, ProjectorDB, ProjectorSource, Source from openlp.core.lib.projector.constants import PJLINK_PORT -from tests.functional import MagicMock, patch from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA, TEST3_DATA diff --git a/tests/functional/openlp_core_lib/test_renderer.py b/tests/functional/openlp_core_lib/test_renderer.py index a2a156094..40c836d60 100644 --- a/tests/functional/openlp_core_lib/test_renderer.py +++ b/tests/functional/openlp_core_lib/test_renderer.py @@ -23,6 +23,7 @@ Package to test the openlp.core.ui.renderer package. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtCore @@ -31,7 +32,6 @@ from openlp.core.lib import Renderer, ScreenList, ServiceItem, FormattingTags from openlp.core.lib.renderer import words_split, get_start_tags from openlp.core.lib.theme import ThemeXML -from tests.functional import MagicMock, patch SCREEN = { 'primary': False, diff --git a/tests/functional/openlp_core_lib/test_screen.py b/tests/functional/openlp_core_lib/test_screen.py index 02df4a1c3..cfb705624 100644 --- a/tests/functional/openlp_core_lib/test_screen.py +++ b/tests/functional/openlp_core_lib/test_screen.py @@ -23,12 +23,12 @@ Package to test the openlp.core.lib.screenlist package. """ from unittest import TestCase +from unittest.mock import MagicMock from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry from openlp.core.lib import ScreenList -from tests.functional import MagicMock SCREEN = { 'primary': False, diff --git a/tests/functional/openlp_core_lib/test_serviceitem.py b/tests/functional/openlp_core_lib/test_serviceitem.py index 11912cf27..bcf2df959 100644 --- a/tests/functional/openlp_core_lib/test_serviceitem.py +++ b/tests/functional/openlp_core_lib/test_serviceitem.py @@ -24,13 +24,13 @@ Package to test the openlp.core.lib package. """ import os from unittest import TestCase - -from tests.functional import MagicMock, patch -from tests.utils import assert_length, convert_file_service_item +from unittest.mock import MagicMock, patch from openlp.core.common import Registry, md5_hash from openlp.core.lib import ItemCapabilities, ServiceItem, ServiceItemType, FormattingTags +from tests.utils import assert_length, convert_file_service_item + VERSE = 'The Lord said to {r}Noah{/r}: \n'\ 'There\'s gonna be a {su}floody{/su}, {sb}floody{/sb}\n'\ 'The Lord said to {g}Noah{/g}:\n'\ diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index 40ea642e1..28ff17122 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -22,14 +22,15 @@ """ Package to test the openlp.core.lib.ui package. """ -from PyQt5 import QtCore, QtGui, QtWidgets from unittest import TestCase +from unittest.mock import MagicMock, patch + +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import UiStrings, translate from openlp.core.lib.ui import add_welcome_page, create_button_box, create_horizontal_adjusting_combo_box, \ create_button, create_action, create_valign_selection_widgets, find_and_set_in_combo_box, create_widget_action, \ set_case_insensitive_completer -from tests.functional import MagicMock, patch class TestUi(TestCase): diff --git a/tests/functional/openlp_core_ui/test_aboutform.py b/tests/functional/openlp_core_ui/test_aboutform.py index 060876fbd..817c13c48 100644 --- a/tests/functional/openlp_core_ui/test_aboutform.py +++ b/tests/functional/openlp_core_ui/test_aboutform.py @@ -24,10 +24,10 @@ Package to test the openlp.core.ui.firsttimeform package. """ import datetime from unittest import TestCase +from unittest.mock import patch from openlp.core.ui.aboutform import AboutForm -from tests.functional import patch from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_core_ui/test_exceptionform.py b/tests/functional/openlp_core_ui/test_exceptionform.py index 31be2efb5..f205a4ce2 100644 --- a/tests/functional/openlp_core_ui/test_exceptionform.py +++ b/tests/functional/openlp_core_ui/test_exceptionform.py @@ -26,15 +26,13 @@ Package to test the openlp.core.ui.exeptionform package. import os import tempfile from unittest import TestCase -from unittest.mock import mock_open +from unittest.mock import mock_open, patch from openlp.core.common import Registry - -from tests.functional import patch -from tests.helpers.testmixin import TestMixin - from openlp.core.ui import exceptionform +from tests.helpers.testmixin import TestMixin + exceptionform.WEBKIT_VERSION = 'Webkit Test' exceptionform.MIGRATE_VERSION = 'Migrate Test' exceptionform.CHARDET_VERSION = 'CHARDET Test' diff --git a/tests/functional/openlp_core_ui/test_first_time.py b/tests/functional/openlp_core_ui/test_first_time.py index 606b1cb7d..35507e15e 100644 --- a/tests/functional/openlp_core_ui/test_first_time.py +++ b/tests/functional/openlp_core_ui/test_first_time.py @@ -22,17 +22,16 @@ """ Package to test the openlp.core.utils.__init__ package. """ - -from unittest import TestCase import urllib.request import urllib.error import urllib.parse - -from tests.functional import patch -from tests.helpers.testmixin import TestMixin +from unittest import TestCase +from unittest.mock import patch from openlp.core.common.httputils import CONNECTION_RETRIES, get_web_page +from tests.helpers.testmixin import TestMixin + class TestFirstTimeWizard(TestMixin, TestCase): """ diff --git a/tests/functional/openlp_core_ui/test_firsttimeform.py b/tests/functional/openlp_core_ui/test_firsttimeform.py index 0710389d1..2203ea63c 100644 --- a/tests/functional/openlp_core_ui/test_firsttimeform.py +++ b/tests/functional/openlp_core_ui/test_firsttimeform.py @@ -26,11 +26,11 @@ import os import tempfile import urllib from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core.common import Registry from openlp.core.ui.firsttimeform import FirstTimeForm -from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin FAKE_CONFIG = b""" diff --git a/tests/functional/openlp_core_ui/test_formattingtagsform.py b/tests/functional/openlp_core_ui/test_formattingtagsform.py index 0e7979bfb..bb9534439 100644 --- a/tests/functional/openlp_core_ui/test_formattingtagsform.py +++ b/tests/functional/openlp_core_ui/test_formattingtagsform.py @@ -23,8 +23,7 @@ Package to test the openlp.core.ui.formattingtagsform package. """ from unittest import TestCase - -from tests.functional import MagicMock, patch, call +from unittest.mock import MagicMock, patch, call from openlp.core.ui.formattingtagform import FormattingTagForm diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py index 467464962..86aaf5ea7 100644 --- a/tests/functional/openlp_core_ui/test_maindisplay.py +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -23,6 +23,7 @@ Package to test the openlp.core.ui.slidecontroller package. """ from unittest import TestCase, skipUnless +from unittest.mock import MagicMock, patch from PyQt5 import QtCore @@ -33,11 +34,9 @@ from openlp.core.ui.media import MediaController from openlp.core.ui.maindisplay import TRANSPARENT_STYLESHEET, OPAQUE_STYLESHEET from tests.helpers.testmixin import TestMixin -from tests.functional import MagicMock, patch if is_macosx(): from ctypes import pythonapi, c_void_p, c_char_p, py_object - from sip import voidptr from objc import objc_object from AppKit import NSMainMenuWindowLevel, NSWindowCollectionBehaviorManaged diff --git a/tests/functional/openlp_core_ui/test_mainwindow.py b/tests/functional/openlp_core_ui/test_mainwindow.py index 0578adaa7..e5f9dd745 100644 --- a/tests/functional/openlp_core_ui/test_mainwindow.py +++ b/tests/functional/openlp_core_ui/test_mainwindow.py @@ -23,8 +23,8 @@ Package to test openlp.core.ui.mainwindow package. """ import os - from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtWidgets @@ -32,7 +32,6 @@ from openlp.core.ui.mainwindow import MainWindow from openlp.core.lib.ui import UiStrings from openlp.core.common.registry import Registry -from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin from tests.utils.constants import TEST_RESOURCES_PATH diff --git a/tests/functional/openlp_core_ui/test_media.py b/tests/functional/openlp_core_ui/test_media.py index b19cd894f..a3c2217fb 100644 --- a/tests/functional/openlp_core_ui/test_media.py +++ b/tests/functional/openlp_core_ui/test_media.py @@ -22,12 +22,13 @@ """ Package to test the openlp.core.ui package. """ -from PyQt5 import QtCore from unittest import TestCase +from unittest.mock import patch + +from PyQt5 import QtCore from openlp.core.ui.media import get_media_players, parse_optical_path -from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_core_ui/test_servicemanager.py b/tests/functional/openlp_core_ui/test_servicemanager.py index c5610d638..589f6e28d 100644 --- a/tests/functional/openlp_core_ui/test_servicemanager.py +++ b/tests/functional/openlp_core_ui/test_servicemanager.py @@ -24,15 +24,14 @@ Package to test the openlp.core.ui.slidecontroller package. """ import os from unittest import TestCase +from unittest.mock import MagicMock, patch import PyQt5 from openlp.core.common import Registry, ThemeLevel -from openlp.core.ui.lib.toolbar import OpenLPToolbar from openlp.core.lib import ServiceItem, ServiceItemType, ItemCapabilities from openlp.core.ui import ServiceManager - -from tests.functional import MagicMock, patch +from openlp.core.ui.lib.toolbar import OpenLPToolbar class TestServiceManager(TestCase): diff --git a/tests/functional/openlp_core_ui/test_settingsform.py b/tests/functional/openlp_core_ui/test_settingsform.py index 16f4dc946..2c8f8fdfe 100644 --- a/tests/functional/openlp_core_ui/test_settingsform.py +++ b/tests/functional/openlp_core_ui/test_settingsform.py @@ -22,14 +22,14 @@ """ Package to test the openlp.core.ui.settingsform package. """ -from PyQt5 import QtWidgets from unittest import TestCase +from unittest.mock import MagicMock, patch + +from PyQt5 import QtWidgets from openlp.core.common import Registry from openlp.core.ui.settingsform import SettingsForm -from tests.functional import MagicMock, patch - class TestSettingsForm(TestCase): diff --git a/tests/functional/openlp_core_ui/test_shortcutlistdialog.py b/tests/functional/openlp_core_ui/test_shortcutlistdialog.py index 55ecf39cb..76f4e2b9e 100644 --- a/tests/functional/openlp_core_ui/test_shortcutlistdialog.py +++ b/tests/functional/openlp_core_ui/test_shortcutlistdialog.py @@ -22,12 +22,12 @@ """ Package to test the openlp.core.ui.shortcutlistdialog package. """ -from PyQt5 import QtCore, QtGui, QtWidgets +from unittest.mock import MagicMock + +from PyQt5 import QtCore from openlp.core.ui.shortcutlistdialog import CaptureShortcutButton, ShortcutTreeWidget -from tests.interfaces import MagicMock, patch - def test_key_press_event(): """ diff --git a/tests/functional/openlp_core_ui/test_slidecontroller.py b/tests/functional/openlp_core_ui/test_slidecontroller.py index 7b0fdfd55..d86610ab3 100644 --- a/tests/functional/openlp_core_ui/test_slidecontroller.py +++ b/tests/functional/openlp_core_ui/test_slidecontroller.py @@ -22,16 +22,16 @@ """ Package to test the openlp.core.ui.slidecontroller package. """ +from unittest import TestCase +from unittest.mock import MagicMock, patch + from PyQt5 import QtCore, QtGui -from unittest import TestCase from openlp.core import Registry from openlp.core.lib import ImageSource, ServiceItemAction from openlp.core.ui import SlideController, LiveController, PreviewController from openlp.core.ui.slidecontroller import InfoLabel, WIDE_MENU, NON_TEXT_MENU -from tests.functional import MagicMock, patch - class TestSlideController(TestCase): diff --git a/tests/functional/openlp_core_ui/test_themeform.py b/tests/functional/openlp_core_ui/test_themeform.py index fcb5313dc..c40f6d85e 100644 --- a/tests/functional/openlp_core_ui/test_themeform.py +++ b/tests/functional/openlp_core_ui/test_themeform.py @@ -22,13 +22,11 @@ """ Package to test the openlp.core.ui.themeform package. """ - from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core.ui import ThemeForm -from tests.functional import MagicMock, patch - class TestThemeManager(TestCase): """ diff --git a/tests/functional/openlp_core_ui/test_thememanager.py b/tests/functional/openlp_core_ui/test_thememanager.py index 264a9f3ce..b0196d048 100644 --- a/tests/functional/openlp_core_ui/test_thememanager.py +++ b/tests/functional/openlp_core_ui/test_thememanager.py @@ -24,18 +24,16 @@ Package to test the openlp.core.ui.thememanager package. """ import os import shutil - -from unittest import TestCase from tempfile import mkdtemp +from unittest import TestCase +from unittest.mock import ANY, MagicMock, patch from PyQt5 import QtWidgets -from tempfile import mkdtemp from openlp.core.ui import ThemeManager from openlp.core.common import Registry from tests.utils.constants import TEST_RESOURCES_PATH -from tests.functional import ANY, MagicMock, patch class TestThemeManager(TestCase): diff --git a/tests/functional/openlp_core_ui/test_themetab.py b/tests/functional/openlp_core_ui/test_themetab.py index 6acc3fdf8..8c562f158 100644 --- a/tests/functional/openlp_core_ui/test_themetab.py +++ b/tests/functional/openlp_core_ui/test_themetab.py @@ -23,13 +23,13 @@ Package to test the openlp.core.ui.ThemeTab package. """ from unittest import TestCase +from unittest.mock import MagicMock from openlp.core.common import Registry from openlp.core.ui.themestab import ThemesTab from openlp.core.ui.settingsform import SettingsForm from tests.helpers.testmixin import TestMixin -from tests.functional import MagicMock class TestThemeTab(TestCase, TestMixin): diff --git a/tests/functional/openlp_core_ui_lib/test_color_button.py b/tests/functional/openlp_core_ui_lib/test_color_button.py index 798adaabc..d795e92e8 100644 --- a/tests/functional/openlp_core_ui_lib/test_color_button.py +++ b/tests/functional/openlp_core_ui_lib/test_color_button.py @@ -23,9 +23,9 @@ This module contains tests for the openlp.core.lib.filedialog module """ from unittest import TestCase +from unittest.mock import MagicMock, call, patch from openlp.core.ui.lib.colorbutton import ColorButton -from tests.functional import MagicMock, call, patch class TestColorDialog(TestCase): diff --git a/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py b/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py index 54d254d80..77c63bb91 100644 --- a/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py +++ b/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py @@ -23,6 +23,7 @@ Package to test the openlp.core.ui.lib.listpreviewwidget package. """ from unittest import TestCase +from unittest.mock import MagicMock, patch, call from PyQt5 import QtGui @@ -30,8 +31,6 @@ from openlp.core.common import Settings from openlp.core.ui.lib.listpreviewwidget import ListPreviewWidget from openlp.core.lib import ImageSource, ServiceItem -from tests.functional import MagicMock, patch, call - class TestListPreviewWidget(TestCase): diff --git a/tests/functional/openlp_core_ui_media/test_mediacontroller.py b/tests/functional/openlp_core_ui_media/test_mediacontroller.py index f6b9c017b..318623434 100644 --- a/tests/functional/openlp_core_ui_media/test_mediacontroller.py +++ b/tests/functional/openlp_core_ui_media/test_mediacontroller.py @@ -23,12 +23,12 @@ Package to test the openlp.core.ui.media package. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core.ui.media.mediacontroller import MediaController from openlp.core.ui.media.mediaplayer import MediaPlayer from openlp.core.common import Registry -from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_core_ui_media/test_systemplayer.py b/tests/functional/openlp_core_ui_media/test_systemplayer.py index a4b2f7cd2..e62133a0c 100644 --- a/tests/functional/openlp_core_ui_media/test_systemplayer.py +++ b/tests/functional/openlp_core_ui_media/test_systemplayer.py @@ -23,6 +23,7 @@ Package to test the openlp.core.ui.media.systemplayer package. """ from unittest import TestCase +from unittest.mock import MagicMock, call, patch from PyQt5 import QtCore, QtMultimedia @@ -30,8 +31,6 @@ from openlp.core.common import Registry from openlp.core.ui.media import MediaState from openlp.core.ui.media.systemplayer import SystemPlayer, CheckMediaWorker, ADDITIONAL_EXT -from tests.functional import MagicMock, call, patch - class TestSystemPlayer(TestCase): """ diff --git a/tests/functional/openlp_core_ui_media/test_vlcplayer.py b/tests/functional/openlp_core_ui_media/test_vlcplayer.py index a1ebb0afe..28ebd55fe 100644 --- a/tests/functional/openlp_core_ui_media/test_vlcplayer.py +++ b/tests/functional/openlp_core_ui_media/test_vlcplayer.py @@ -26,12 +26,12 @@ import os import sys from datetime import datetime, timedelta from unittest import TestCase, skip +from unittest.mock import MagicMock, patch, call from openlp.core.common import Registry from openlp.core.ui.media import MediaState, MediaType from openlp.core.ui.media.vlcplayer import AUDIO_EXT, VIDEO_EXT, VlcPlayer, get_vlc -from tests.functional import MagicMock, patch, call from tests.helpers import MockDateTime from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_core_ui_media/test_webkitplayer.py b/tests/functional/openlp_core_ui_media/test_webkitplayer.py index bf9f1f22e..cba946338 100644 --- a/tests/functional/openlp_core_ui_media/test_webkitplayer.py +++ b/tests/functional/openlp_core_ui_media/test_webkitplayer.py @@ -23,7 +23,7 @@ Package to test the openlp.core.ui.media.webkitplayer package. """ from unittest import TestCase -from tests.functional import MagicMock, patch +from unittest.mock import MagicMock, patch from openlp.core.ui.media.webkitplayer import WebkitPlayer diff --git a/tests/functional/openlp_plugins/alerts/test_manager.py b/tests/functional/openlp_plugins/alerts/test_manager.py index 045f44f47..c286e81cd 100644 --- a/tests/functional/openlp_plugins/alerts/test_manager.py +++ b/tests/functional/openlp_plugins/alerts/test_manager.py @@ -22,12 +22,11 @@ """ This module contains tests for the CSV Bible importer. """ - import os import json from unittest import TestCase +from unittest.mock import MagicMock, patch -from tests.functional import MagicMock, patch from openlp.core.common.registry import Registry from openlp.plugins.alerts.lib.alertsmanager import AlertsManager diff --git a/tests/functional/openlp_plugins/bibles/test_bibleimport.py b/tests/functional/openlp_plugins/bibles/test_bibleimport.py index a2244dbf7..b28ab0dfa 100644 --- a/tests/functional/openlp_plugins/bibles/test_bibleimport.py +++ b/tests/functional/openlp_plugins/bibles/test_bibleimport.py @@ -22,18 +22,17 @@ """ This module contains tests for the bibleimport module. """ - from io import BytesIO -from lxml import etree, objectify - from unittest import TestCase +from unittest.mock import MagicMock, patch + +from lxml import etree, objectify from PyQt5.QtWidgets import QDialog from openlp.core.common.languages import Language from openlp.core.lib.exceptions import ValidationError from openlp.plugins.bibles.lib.bibleimport import BibleImport from openlp.plugins.bibles.lib.db import BibleDB -from tests.functional import MagicMock, patch class TestBibleImport(TestCase): diff --git a/tests/functional/openlp_plugins/bibles/test_bibleserver.py b/tests/functional/openlp_plugins/bibles/test_bibleserver.py index cd996e84d..a66f8b28e 100644 --- a/tests/functional/openlp_plugins/bibles/test_bibleserver.py +++ b/tests/functional/openlp_plugins/bibles/test_bibleserver.py @@ -23,9 +23,10 @@ This module contains tests for the http module of the Bibles plugin. """ from unittest import TestCase +from unittest.mock import patch, MagicMock + from bs4 import BeautifulSoup -from tests.functional import patch, MagicMock from openlp.plugins.bibles.lib.importers.http import BSExtract # TODO: Items left to test diff --git a/tests/functional/openlp_plugins/bibles/test_csvimport.py b/tests/functional/openlp_plugins/bibles/test_csvimport.py index 446ac433a..63d3d5282 100644 --- a/tests/functional/openlp_plugins/bibles/test_csvimport.py +++ b/tests/functional/openlp_plugins/bibles/test_csvimport.py @@ -22,14 +22,13 @@ """ This module contains tests for the CSV Bible importer. """ - import csv import json import os from collections import namedtuple from unittest import TestCase +from unittest.mock import ANY, MagicMock, PropertyMock, call, patch -from tests.functional import ANY, MagicMock, PropertyMock, call, patch from openlp.core.lib.exceptions import ValidationError from openlp.plugins.bibles.lib.bibleimport import BibleImport from openlp.plugins.bibles.lib.importers.csvbible import Book, CSVBible, Verse diff --git a/tests/functional/openlp_plugins/bibles/test_lib.py b/tests/functional/openlp_plugins/bibles/test_lib.py index 24e9a0534..2c2615a7a 100644 --- a/tests/functional/openlp_plugins/bibles/test_lib.py +++ b/tests/functional/openlp_plugins/bibles/test_lib.py @@ -23,10 +23,11 @@ This module contains tests for the lib submodule of the Bibles plugin. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.plugins.bibles import lib from openlp.plugins.bibles.lib import SearchResults, get_reference_match -from tests.functional import MagicMock, patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_plugins/bibles/test_opensongimport.py b/tests/functional/openlp_plugins/bibles/test_opensongimport.py index 20d408e09..4842e9c5f 100644 --- a/tests/functional/openlp_plugins/bibles/test_opensongimport.py +++ b/tests/functional/openlp_plugins/bibles/test_opensongimport.py @@ -22,19 +22,19 @@ """ This module contains tests for the OpenSong Bible importer. """ - import json import os from unittest import TestCase +from unittest.mock import MagicMock, patch, call from lxml import objectify -from tests.functional import MagicMock, patch, call -from tests.helpers.testmixin import TestMixin from openlp.core.common import Registry from openlp.plugins.bibles.lib.importers.opensong import OpenSongBible, get_text, parse_chapter_number from openlp.plugins.bibles.lib.bibleimport import BibleImport +from tests.helpers.testmixin import TestMixin + TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'bibles')) diff --git a/tests/functional/openlp_plugins/bibles/test_osisimport.py b/tests/functional/openlp_plugins/bibles/test_osisimport.py index 58aace669..5be6c459c 100644 --- a/tests/functional/openlp_plugins/bibles/test_osisimport.py +++ b/tests/functional/openlp_plugins/bibles/test_osisimport.py @@ -22,12 +22,11 @@ """ This module contains tests for the OSIS Bible importer. """ - import os import json from unittest import TestCase +from unittest.mock import MagicMock, call, patch -from tests.functional import MagicMock, call, patch from openlp.plugins.bibles.lib.bibleimport import BibleImport from openlp.plugins.bibles.lib.db import BibleDB from openlp.plugins.bibles.lib.importers.osis import OSISBible diff --git a/tests/functional/openlp_plugins/bibles/test_swordimport.py b/tests/functional/openlp_plugins/bibles/test_swordimport.py index 5aa807e79..235beea58 100644 --- a/tests/functional/openlp_plugins/bibles/test_swordimport.py +++ b/tests/functional/openlp_plugins/bibles/test_swordimport.py @@ -26,13 +26,14 @@ This module contains tests for the SWORD Bible importer. import os import json from unittest import TestCase, skipUnless +from unittest.mock import MagicMock, patch -from tests.functional import MagicMock, patch try: from openlp.plugins.bibles.lib.importers.sword import SwordBible HAS_PYSWORD = True except ImportError: HAS_PYSWORD = False + from openlp.plugins.bibles.lib.db import BibleDB TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), diff --git a/tests/functional/openlp_plugins/bibles/test_wordprojectimport.py b/tests/functional/openlp_plugins/bibles/test_wordprojectimport.py index ad24dbcf6..6e62dae9e 100644 --- a/tests/functional/openlp_plugins/bibles/test_wordprojectimport.py +++ b/tests/functional/openlp_plugins/bibles/test_wordprojectimport.py @@ -22,15 +22,12 @@ """ This module contains tests for the WordProject Bible importer. """ - import os -import json from unittest import TestCase +from unittest.mock import MagicMock, patch, call from openlp.plugins.bibles.lib.importers.wordproject import WordProjectBible -from openlp.plugins.bibles.lib.db import BibleDB -from tests.functional import MagicMock, patch, call TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'bibles')) diff --git a/tests/functional/openlp_plugins/bibles/test_zefaniaimport.py b/tests/functional/openlp_plugins/bibles/test_zefaniaimport.py index b97cff57b..8e43d55b5 100644 --- a/tests/functional/openlp_plugins/bibles/test_zefaniaimport.py +++ b/tests/functional/openlp_plugins/bibles/test_zefaniaimport.py @@ -22,12 +22,11 @@ """ This module contains tests for the Zefania Bible importer. """ - import os import json from unittest import TestCase +from unittest.mock import MagicMock, patch -from tests.functional import MagicMock, patch from openlp.plugins.bibles.lib.importers.zefania import ZefaniaBible from openlp.plugins.bibles.lib.db import BibleDB diff --git a/tests/functional/openlp_plugins/custom/test_mediaitem.py b/tests/functional/openlp_plugins/custom/test_mediaitem.py index 6a70f3173..a14ac1fb5 100644 --- a/tests/functional/openlp_plugins/custom/test_mediaitem.py +++ b/tests/functional/openlp_plugins/custom/test_mediaitem.py @@ -1,15 +1,36 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2017 OpenLP Developers # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### """ This module contains tests for the lib submodule of the Songs plugin. """ from unittest import TestCase +from unittest.mock import patch, MagicMock from PyQt5 import QtCore -from openlp.core.common import Registry, Settings +from openlp.core.common import Registry from openlp.core.lib import ServiceItem, PluginStatus from openlp.plugins.custom.lib import CustomMediaItem -from openlp.plugins.custom.lib.db import CustomSlide -from tests.functional import patch, MagicMock + from tests.helpers.testmixin import TestMixin FOOTER = ['Arky Arky (Unknown)', 'Public Domain', 'CCLI 123456'] diff --git a/tests/functional/openlp_plugins/images/test_imagetab.py b/tests/functional/openlp_plugins/images/test_imagetab.py index 74a1fd9ab..b6875fef4 100644 --- a/tests/functional/openlp_plugins/images/test_imagetab.py +++ b/tests/functional/openlp_plugins/images/test_imagetab.py @@ -23,15 +23,15 @@ This module contains tests for the lib submodule of the Images plugin. """ from unittest import TestCase +from unittest.mock import MagicMock, patch + from PyQt5 import QtWidgets -from openlp.core.common import Settings - -from openlp.core.common import Registry +from openlp.core.common import Registry, Settings from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups from openlp.plugins.images.lib.mediaitem import ImageMediaItem from openlp.plugins.images.lib import ImageTab -from tests.functional import MagicMock, patch + from tests.helpers.testmixin import TestMixin __default_settings__ = { diff --git a/tests/functional/openlp_plugins/images/test_lib.py b/tests/functional/openlp_plugins/images/test_lib.py index 3f0c4e621..f00463d67 100644 --- a/tests/functional/openlp_plugins/images/test_lib.py +++ b/tests/functional/openlp_plugins/images/test_lib.py @@ -23,13 +23,13 @@ This module contains tests for the lib submodule of the Images plugin. """ from unittest import TestCase +from unittest.mock import ANY, MagicMock, patch from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups from openlp.plugins.images.lib.mediaitem import ImageMediaItem -from tests.functional import ANY, MagicMock, patch class TestImageMediaItem(TestCase): diff --git a/tests/functional/openlp_plugins/media/test_mediaitem.py b/tests/functional/openlp_plugins/media/test_mediaitem.py index 49771241b..80d21da91 100644 --- a/tests/functional/openlp_plugins/media/test_mediaitem.py +++ b/tests/functional/openlp_plugins/media/test_mediaitem.py @@ -23,15 +23,13 @@ Test the media plugin """ from unittest import TestCase - -from openlp.core import Registry, Settings -from openlp.plugins.media.mediaplugin import MediaPlugin -from openlp.plugins.media.lib.mediaitem import MediaMediaItem -from openlp.core.ui.media.mediacontroller import MediaController +from unittest.mock import MagicMock, patch from PyQt5 import QtCore -from tests.functional import MagicMock, patch +from openlp.core import Settings +from openlp.plugins.media.lib.mediaitem import MediaMediaItem + from tests.helpers.testmixin import TestMixin __default_settings__ = { diff --git a/tests/functional/openlp_plugins/media/test_mediaplugin.py b/tests/functional/openlp_plugins/media/test_mediaplugin.py index ba1e0c30c..a7b89903e 100644 --- a/tests/functional/openlp_plugins/media/test_mediaplugin.py +++ b/tests/functional/openlp_plugins/media/test_mediaplugin.py @@ -23,11 +23,11 @@ Test the media plugin """ from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core import Registry from openlp.plugins.media.mediaplugin import MediaPlugin, process_check_binary -from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_plugins/presentations/test_impresscontroller.py b/tests/functional/openlp_plugins/presentations/test_impresscontroller.py index b2ec83a35..e93c98d39 100644 --- a/tests/functional/openlp_plugins/presentations/test_impresscontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_impresscontroller.py @@ -23,19 +23,19 @@ Functional tests to test the Impress class and related methods. """ from unittest import TestCase +from unittest.mock import patch, MagicMock import os import shutil from tempfile import mkdtemp -from tests.functional import patch, MagicMock -from tests.utils.constants import TEST_RESOURCES_PATH -from tests.helpers.testmixin import TestMixin - from openlp.core.common import Settings from openlp.plugins.presentations.lib.impresscontroller import \ ImpressController, ImpressDocument, TextType from openlp.plugins.presentations.presentationplugin import __default_settings__ +from tests.utils.constants import TEST_RESOURCES_PATH +from tests.helpers.testmixin import TestMixin + class TestImpressController(TestCase, TestMixin): """ diff --git a/tests/functional/openlp_plugins/presentations/test_mediaitem.py b/tests/functional/openlp_plugins/presentations/test_mediaitem.py index e477ad704..b5299d785 100644 --- a/tests/functional/openlp_plugins/presentations/test_mediaitem.py +++ b/tests/functional/openlp_plugins/presentations/test_mediaitem.py @@ -23,10 +23,11 @@ This module contains tests for the lib submodule of the Presentations plugin. """ from unittest import TestCase +from unittest.mock import patch, MagicMock, call from openlp.core.common import Registry from openlp.plugins.presentations.lib.mediaitem import PresentationMediaItem -from tests.functional import patch, MagicMock, call + from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_plugins/presentations/test_messagelistener.py b/tests/functional/openlp_plugins/presentations/test_messagelistener.py index 39238bdd6..f4c268ee1 100644 --- a/tests/functional/openlp_plugins/presentations/test_messagelistener.py +++ b/tests/functional/openlp_plugins/presentations/test_messagelistener.py @@ -23,11 +23,12 @@ This module contains tests for the lib submodule of the Presentations plugin. """ from unittest import TestCase +from unittest.mock import patch, MagicMock from openlp.core.common import Registry from openlp.plugins.presentations.lib.mediaitem import MessageListener, PresentationMediaItem from openlp.plugins.presentations.lib.messagelistener import Controller -from tests.functional import patch, MagicMock + from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py b/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py index 9e5b4c2cd..be4aeeaa4 100644 --- a/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py @@ -24,14 +24,16 @@ This module contains tests for the PdfController """ import os import shutil -from unittest import TestCase, SkipTest from tempfile import mkdtemp +from unittest import TestCase, SkipTest +from unittest.mock import MagicMock, patch + from PyQt5 import QtCore, QtGui from openlp.plugins.presentations.lib.pdfcontroller import PdfController, PdfDocument -from tests.functional import MagicMock, patch from openlp.core.common import Settings from openlp.core.lib import ScreenList + from tests.utils.constants import TEST_RESOURCES_PATH from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py b/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py index 739556eaa..c1deedfa0 100644 --- a/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py @@ -1,303 +1,303 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2017 OpenLP Developers # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### -""" -Functional tests to test the PowerPointController class and related methods. -""" -import os -import shutil -from unittest import TestCase -from tempfile import mkdtemp - -from tests.functional import patch, MagicMock -from tests.helpers.testmixin import TestMixin -from tests.utils.constants import TEST_RESOURCES_PATH - -from openlp.plugins.presentations.lib.powerpointcontroller import PowerpointController, PowerpointDocument,\ - _get_text_from_shapes -from openlp.core.common import is_win, Settings - -if is_win(): - import pywintypes - -__default_settings__ = { - 'presentations/powerpoint slide click advance': True -} - - -class TestPowerpointController(TestCase, TestMixin): - """ - Test the PowerpointController Class - """ - - def setUp(self): - """ - Set up the patches and mocks need for all tests. - """ - self.setup_application() - self.build_settings() - self.mock_plugin = MagicMock() - self.temp_folder = mkdtemp() - self.mock_plugin.settings_section = self.temp_folder - - def tearDown(self): - """ - Stop the patches - """ - self.destroy_settings() - shutil.rmtree(self.temp_folder) - - def test_constructor(self): - """ - Test the Constructor from the PowerpointController - """ - # GIVEN: No presentation controller - controller = None - - # WHEN: The presentation controller object is created - controller = PowerpointController(plugin=self.mock_plugin) - - # THEN: The name of the presentation controller should be correct - self.assertEqual('Powerpoint', controller.name, - 'The name of the presentation controller should be correct') - - -class TestPowerpointDocument(TestCase, TestMixin): - """ - Test the PowerpointDocument Class - """ - - def setUp(self): - """ - Set up the patches and mocks need for all tests. - """ - self.setup_application() - self.build_settings() - self.mock_plugin = MagicMock() - self.temp_folder = mkdtemp() - self.mock_plugin.settings_section = self.temp_folder - self.powerpoint_document_stop_presentation_patcher = patch( - 'openlp.plugins.presentations.lib.powerpointcontroller.PowerpointDocument.stop_presentation') - self.presentation_document_get_temp_folder_patcher = patch( - 'openlp.plugins.presentations.lib.powerpointcontroller.PresentationDocument.get_temp_folder') - self.presentation_document_setup_patcher = patch( - 'openlp.plugins.presentations.lib.powerpointcontroller.PresentationDocument._setup') - self.mock_powerpoint_document_stop_presentation = self.powerpoint_document_stop_presentation_patcher.start() - self.mock_presentation_document_get_temp_folder = self.presentation_document_get_temp_folder_patcher.start() - self.mock_presentation_document_setup = self.presentation_document_setup_patcher.start() - self.mock_controller = MagicMock() - self.mock_presentation = MagicMock() - self.mock_presentation_document_get_temp_folder.return_value = 'temp folder' - self.file_name = os.path.join(TEST_RESOURCES_PATH, 'presentations', 'test.pptx') - self.real_controller = PowerpointController(self.mock_plugin) - Settings().extend_default_settings(__default_settings__) - - def tearDown(self): - """ - Stop the patches - """ - self.powerpoint_document_stop_presentation_patcher.stop() - self.presentation_document_get_temp_folder_patcher.stop() - self.presentation_document_setup_patcher.stop() - self.destroy_settings() - shutil.rmtree(self.temp_folder) - - def test_show_error_msg(self): - """ - Test the PowerpointDocument.show_error_msg() method gets called on com exception - """ - if is_win(): - # GIVEN: A PowerpointDocument with mocked controller and presentation - with patch('openlp.plugins.presentations.lib.powerpointcontroller.critical_error_message_box') as \ - mocked_critical_error_message_box: - instance = PowerpointDocument(self.mock_controller, self.mock_presentation) - instance.presentation = MagicMock() - instance.presentation.SlideShowWindow.View.GotoSlide = MagicMock(side_effect=pywintypes.com_error('1')) - instance.index_map[42] = 42 - - # WHEN: Calling goto_slide which will throw an exception - instance.goto_slide(42) - - # THEN: mocked_critical_error_message_box should have been called - mocked_critical_error_message_box.assert_called_with('Error', 'An error occurred in the PowerPoint ' - 'integration and the presentation will be stopped.' - ' Restart the presentation if you wish to ' - 'present it.') - - # add _test to the following if necessary - def verify_loading_document(self): - """ - Test loading a document in PowerPoint - """ - if is_win() and self.real_controller.check_available(): - # GIVEN: A PowerpointDocument and a presentation - doc = PowerpointDocument(self.real_controller, self.file_name) - - # WHEN: loading the filename - doc.load_presentation() - result = doc.is_loaded() - - # THEN: result should be true - self.assertEqual(result, True, 'The result should be True') - else: - self.skipTest('Powerpoint not available, skipping test.') - - def test_create_titles_and_notes(self): - """ - Test creating the titles from PowerPoint - """ - # GIVEN: mocked save_titles_and_notes, _get_text_from_shapes and two mocked slides - self.doc = PowerpointDocument(self.mock_controller, self.file_name) - self.doc.get_slide_count = MagicMock() - self.doc.get_slide_count.return_value = 2 - self.doc.index_map = {1: 1, 2: 2} - self.doc.save_titles_and_notes = MagicMock() - self.doc._PowerpointDocument__get_text_from_shapes = MagicMock() - slide = MagicMock() - slide.Shapes.Title.TextFrame.TextRange.Text = 'SlideText' - pres = MagicMock() - pres.Slides = MagicMock(side_effect=[slide, slide]) - self.doc.presentation = pres - - # WHEN reading the titles and notes - self.doc.create_titles_and_notes() - - # THEN the save should have been called exactly once with 2 titles and 2 notes - self.doc.save_titles_and_notes.assert_called_once_with(['SlideText\n', 'SlideText\n'], [' ', ' ']) - - def test_create_titles_and_notes_with_no_slides(self): - """ - Test creating the titles from PowerPoint when it returns no slides - """ - # GIVEN: mocked save_titles_and_notes, _get_text_from_shapes and two mocked slides - doc = PowerpointDocument(self.mock_controller, self.file_name) - doc.save_titles_and_notes = MagicMock() - doc._PowerpointDocument__get_text_from_shapes = MagicMock() - pres = MagicMock() - pres.Slides = [] - doc.presentation = pres - - # WHEN reading the titles and notes - doc.create_titles_and_notes() - - # THEN the save should have been called exactly once with empty titles and notes - doc.save_titles_and_notes.assert_called_once_with([], []) - - def test_get_text_from_shapes(self): - """ - Test getting text from powerpoint shapes - """ - # GIVEN: mocked shapes - shape = MagicMock() - shape.PlaceholderFormat.Type = 2 - shape.HasTextFrame = shape.TextFrame.HasText = True - shape.TextFrame.TextRange.Text = 'slideText' - shapes = [shape, shape] - - # WHEN: getting the text - result = _get_text_from_shapes(shapes) - - # THEN: it should return the text - self.assertEqual(result, 'slideText\nslideText\n', 'result should match \'slideText\nslideText\n\'') - - def test_get_text_from_shapes_with_no_shapes(self): - """ - Test getting text from powerpoint shapes with no shapes - """ - # GIVEN: empty shapes array - shapes = [] - - # WHEN: getting the text - result = _get_text_from_shapes(shapes) - - # THEN: it should not fail but return empty string - self.assertEqual(result, '', 'result should be empty') - - def test_goto_slide(self): - """ - Test that goto_slide goes to next effect if the slide is already displayed - """ - # GIVEN: A Document with mocked controller, presentation, and mocked functions get_slide_number and next_step - doc = PowerpointDocument(self.mock_controller, self.mock_presentation) - doc.presentation = MagicMock() - doc.presentation.SlideShowWindow.View.GetClickIndex.return_value = 1 - doc.presentation.SlideShowWindow.View.GetClickCount.return_value = 2 - doc.get_slide_number = MagicMock() - doc.get_slide_number.return_value = 1 - doc.next_step = MagicMock() - doc.index_map[1] = 1 - - # WHEN: Calling goto_slide - doc.goto_slide(1) - - # THEN: next_step() should be call to try to advance to the next effect. - self.assertTrue(doc.next_step.called, 'next_step() should have been called!') - - def test_blank_screen(self): - """ - Test that blank_screen works as expected - """ - # GIVEN: A Document with mocked controller, presentation, and mocked function get_slide_number - doc = PowerpointDocument(self.mock_controller, self.mock_presentation) - doc.presentation = MagicMock() - doc.presentation.SlideShowWindow.View.GetClickIndex.return_value = 3 - doc.presentation.Application.Version = 14.0 - doc.get_slide_number = MagicMock() - doc.get_slide_number.return_value = 2 - - # WHEN: Calling goto_slide - doc.blank_screen() - - # THEN: The view state, doc.blank_slide and doc.blank_click should have new values - self.assertEquals(doc.presentation.SlideShowWindow.View.State, 3, 'The View State should be 3') - self.assertEquals(doc.blank_slide, 2, 'doc.blank_slide should be 2 because of the PowerPoint version') - self.assertEquals(doc.blank_click, 3, 'doc.blank_click should be 3 because of the PowerPoint version') - - def test_unblank_screen(self): - """ - Test that unblank_screen works as expected - """ - # GIVEN: A Document with mocked controller, presentation, ScreenList, and mocked function get_slide_number - with patch('openlp.plugins.presentations.lib.powerpointcontroller.ScreenList') as mocked_screen_list: - mocked_screen_list_ret = MagicMock() - mocked_screen_list_ret.screen_list = [1] - mocked_screen_list.return_value = mocked_screen_list_ret - doc = PowerpointDocument(self.mock_controller, self.mock_presentation) - doc.presentation = MagicMock() - doc.presentation.SlideShowWindow.View.GetClickIndex.return_value = 3 - doc.presentation.Application.Version = 14.0 - doc.get_slide_number = MagicMock() - doc.get_slide_number.return_value = 2 - doc.index_map[1] = 1 - doc.blank_slide = 1 - doc.blank_click = 1 - - # WHEN: Calling goto_slide - doc.unblank_screen() - - # THEN: The view state have new value, and several function should have been called - self.assertEquals(doc.presentation.SlideShowWindow.View.State, 1, 'The View State should be 1') - self.assertEquals(doc.presentation.SlideShowWindow.Activate.called, True, - 'SlideShowWindow.Activate should have been called') - self.assertEquals(doc.presentation.SlideShowWindow.View.GotoSlide.called, True, - 'View.GotoSlide should have been called because of the PowerPoint version') - self.assertEquals(doc.presentation.SlideShowWindow.View.GotoClick.called, True, - 'View.GotoClick should have been called because of the PowerPoint version') +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2017 OpenLP Developers # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +Functional tests to test the PowerPointController class and related methods. +""" +import os +import shutil +from unittest import TestCase +from unittest.mock import patch, MagicMock +from tempfile import mkdtemp + +from openlp.plugins.presentations.lib.powerpointcontroller import PowerpointController, PowerpointDocument,\ + _get_text_from_shapes +from openlp.core.common import is_win, Settings + +from tests.helpers.testmixin import TestMixin +from tests.utils.constants import TEST_RESOURCES_PATH + +if is_win(): + import pywintypes + +__default_settings__ = { + 'presentations/powerpoint slide click advance': True +} + + +class TestPowerpointController(TestCase, TestMixin): + """ + Test the PowerpointController Class + """ + + def setUp(self): + """ + Set up the patches and mocks need for all tests. + """ + self.setup_application() + self.build_settings() + self.mock_plugin = MagicMock() + self.temp_folder = mkdtemp() + self.mock_plugin.settings_section = self.temp_folder + + def tearDown(self): + """ + Stop the patches + """ + self.destroy_settings() + shutil.rmtree(self.temp_folder) + + def test_constructor(self): + """ + Test the Constructor from the PowerpointController + """ + # GIVEN: No presentation controller + controller = None + + # WHEN: The presentation controller object is created + controller = PowerpointController(plugin=self.mock_plugin) + + # THEN: The name of the presentation controller should be correct + self.assertEqual('Powerpoint', controller.name, + 'The name of the presentation controller should be correct') + + +class TestPowerpointDocument(TestCase, TestMixin): + """ + Test the PowerpointDocument Class + """ + + def setUp(self): + """ + Set up the patches and mocks need for all tests. + """ + self.setup_application() + self.build_settings() + self.mock_plugin = MagicMock() + self.temp_folder = mkdtemp() + self.mock_plugin.settings_section = self.temp_folder + self.powerpoint_document_stop_presentation_patcher = patch( + 'openlp.plugins.presentations.lib.powerpointcontroller.PowerpointDocument.stop_presentation') + self.presentation_document_get_temp_folder_patcher = patch( + 'openlp.plugins.presentations.lib.powerpointcontroller.PresentationDocument.get_temp_folder') + self.presentation_document_setup_patcher = patch( + 'openlp.plugins.presentations.lib.powerpointcontroller.PresentationDocument._setup') + self.mock_powerpoint_document_stop_presentation = self.powerpoint_document_stop_presentation_patcher.start() + self.mock_presentation_document_get_temp_folder = self.presentation_document_get_temp_folder_patcher.start() + self.mock_presentation_document_setup = self.presentation_document_setup_patcher.start() + self.mock_controller = MagicMock() + self.mock_presentation = MagicMock() + self.mock_presentation_document_get_temp_folder.return_value = 'temp folder' + self.file_name = os.path.join(TEST_RESOURCES_PATH, 'presentations', 'test.pptx') + self.real_controller = PowerpointController(self.mock_plugin) + Settings().extend_default_settings(__default_settings__) + + def tearDown(self): + """ + Stop the patches + """ + self.powerpoint_document_stop_presentation_patcher.stop() + self.presentation_document_get_temp_folder_patcher.stop() + self.presentation_document_setup_patcher.stop() + self.destroy_settings() + shutil.rmtree(self.temp_folder) + + def test_show_error_msg(self): + """ + Test the PowerpointDocument.show_error_msg() method gets called on com exception + """ + if is_win(): + # GIVEN: A PowerpointDocument with mocked controller and presentation + with patch('openlp.plugins.presentations.lib.powerpointcontroller.critical_error_message_box') as \ + mocked_critical_error_message_box: + instance = PowerpointDocument(self.mock_controller, self.mock_presentation) + instance.presentation = MagicMock() + instance.presentation.SlideShowWindow.View.GotoSlide = MagicMock(side_effect=pywintypes.com_error('1')) + instance.index_map[42] = 42 + + # WHEN: Calling goto_slide which will throw an exception + instance.goto_slide(42) + + # THEN: mocked_critical_error_message_box should have been called + mocked_critical_error_message_box.assert_called_with('Error', 'An error occurred in the PowerPoint ' + 'integration and the presentation will be stopped.' + ' Restart the presentation if you wish to ' + 'present it.') + + # add _test to the following if necessary + def verify_loading_document(self): + """ + Test loading a document in PowerPoint + """ + if is_win() and self.real_controller.check_available(): + # GIVEN: A PowerpointDocument and a presentation + doc = PowerpointDocument(self.real_controller, self.file_name) + + # WHEN: loading the filename + doc.load_presentation() + result = doc.is_loaded() + + # THEN: result should be true + self.assertEqual(result, True, 'The result should be True') + else: + self.skipTest('Powerpoint not available, skipping test.') + + def test_create_titles_and_notes(self): + """ + Test creating the titles from PowerPoint + """ + # GIVEN: mocked save_titles_and_notes, _get_text_from_shapes and two mocked slides + self.doc = PowerpointDocument(self.mock_controller, self.file_name) + self.doc.get_slide_count = MagicMock() + self.doc.get_slide_count.return_value = 2 + self.doc.index_map = {1: 1, 2: 2} + self.doc.save_titles_and_notes = MagicMock() + self.doc._PowerpointDocument__get_text_from_shapes = MagicMock() + slide = MagicMock() + slide.Shapes.Title.TextFrame.TextRange.Text = 'SlideText' + pres = MagicMock() + pres.Slides = MagicMock(side_effect=[slide, slide]) + self.doc.presentation = pres + + # WHEN reading the titles and notes + self.doc.create_titles_and_notes() + + # THEN the save should have been called exactly once with 2 titles and 2 notes + self.doc.save_titles_and_notes.assert_called_once_with(['SlideText\n', 'SlideText\n'], [' ', ' ']) + + def test_create_titles_and_notes_with_no_slides(self): + """ + Test creating the titles from PowerPoint when it returns no slides + """ + # GIVEN: mocked save_titles_and_notes, _get_text_from_shapes and two mocked slides + doc = PowerpointDocument(self.mock_controller, self.file_name) + doc.save_titles_and_notes = MagicMock() + doc._PowerpointDocument__get_text_from_shapes = MagicMock() + pres = MagicMock() + pres.Slides = [] + doc.presentation = pres + + # WHEN reading the titles and notes + doc.create_titles_and_notes() + + # THEN the save should have been called exactly once with empty titles and notes + doc.save_titles_and_notes.assert_called_once_with([], []) + + def test_get_text_from_shapes(self): + """ + Test getting text from powerpoint shapes + """ + # GIVEN: mocked shapes + shape = MagicMock() + shape.PlaceholderFormat.Type = 2 + shape.HasTextFrame = shape.TextFrame.HasText = True + shape.TextFrame.TextRange.Text = 'slideText' + shapes = [shape, shape] + + # WHEN: getting the text + result = _get_text_from_shapes(shapes) + + # THEN: it should return the text + self.assertEqual(result, 'slideText\nslideText\n', 'result should match \'slideText\nslideText\n\'') + + def test_get_text_from_shapes_with_no_shapes(self): + """ + Test getting text from powerpoint shapes with no shapes + """ + # GIVEN: empty shapes array + shapes = [] + + # WHEN: getting the text + result = _get_text_from_shapes(shapes) + + # THEN: it should not fail but return empty string + self.assertEqual(result, '', 'result should be empty') + + def test_goto_slide(self): + """ + Test that goto_slide goes to next effect if the slide is already displayed + """ + # GIVEN: A Document with mocked controller, presentation, and mocked functions get_slide_number and next_step + doc = PowerpointDocument(self.mock_controller, self.mock_presentation) + doc.presentation = MagicMock() + doc.presentation.SlideShowWindow.View.GetClickIndex.return_value = 1 + doc.presentation.SlideShowWindow.View.GetClickCount.return_value = 2 + doc.get_slide_number = MagicMock() + doc.get_slide_number.return_value = 1 + doc.next_step = MagicMock() + doc.index_map[1] = 1 + + # WHEN: Calling goto_slide + doc.goto_slide(1) + + # THEN: next_step() should be call to try to advance to the next effect. + self.assertTrue(doc.next_step.called, 'next_step() should have been called!') + + def test_blank_screen(self): + """ + Test that blank_screen works as expected + """ + # GIVEN: A Document with mocked controller, presentation, and mocked function get_slide_number + doc = PowerpointDocument(self.mock_controller, self.mock_presentation) + doc.presentation = MagicMock() + doc.presentation.SlideShowWindow.View.GetClickIndex.return_value = 3 + doc.presentation.Application.Version = 14.0 + doc.get_slide_number = MagicMock() + doc.get_slide_number.return_value = 2 + + # WHEN: Calling goto_slide + doc.blank_screen() + + # THEN: The view state, doc.blank_slide and doc.blank_click should have new values + self.assertEquals(doc.presentation.SlideShowWindow.View.State, 3, 'The View State should be 3') + self.assertEquals(doc.blank_slide, 2, 'doc.blank_slide should be 2 because of the PowerPoint version') + self.assertEquals(doc.blank_click, 3, 'doc.blank_click should be 3 because of the PowerPoint version') + + def test_unblank_screen(self): + """ + Test that unblank_screen works as expected + """ + # GIVEN: A Document with mocked controller, presentation, ScreenList, and mocked function get_slide_number + with patch('openlp.plugins.presentations.lib.powerpointcontroller.ScreenList') as mocked_screen_list: + mocked_screen_list_ret = MagicMock() + mocked_screen_list_ret.screen_list = [1] + mocked_screen_list.return_value = mocked_screen_list_ret + doc = PowerpointDocument(self.mock_controller, self.mock_presentation) + doc.presentation = MagicMock() + doc.presentation.SlideShowWindow.View.GetClickIndex.return_value = 3 + doc.presentation.Application.Version = 14.0 + doc.get_slide_number = MagicMock() + doc.get_slide_number.return_value = 2 + doc.index_map[1] = 1 + doc.blank_slide = 1 + doc.blank_click = 1 + + # WHEN: Calling goto_slide + doc.unblank_screen() + + # THEN: The view state have new value, and several function should have been called + self.assertEquals(doc.presentation.SlideShowWindow.View.State, 1, 'The View State should be 1') + self.assertEquals(doc.presentation.SlideShowWindow.Activate.called, True, + 'SlideShowWindow.Activate should have been called') + self.assertEquals(doc.presentation.SlideShowWindow.View.GotoSlide.called, True, + 'View.GotoSlide should have been called because of the PowerPoint version') + self.assertEquals(doc.presentation.SlideShowWindow.View.GotoClick.called, True, + 'View.GotoClick should have been called because of the PowerPoint version') diff --git a/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py b/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py index 4e97a554b..88544f0e9 100644 --- a/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py @@ -24,17 +24,16 @@ This module contains tests for the pptviewcontroller module of the Presentations """ import os import shutil - from tempfile import mkdtemp from unittest import TestCase - -from tests.functional import MagicMock, patch -from tests.helpers.testmixin import TestMixin -from tests.utils.constants import TEST_RESOURCES_PATH +from unittest.mock import MagicMock, patch from openlp.plugins.presentations.lib.pptviewcontroller import PptviewDocument, PptviewController from openlp.core.common import is_win +from tests.helpers.testmixin import TestMixin +from tests.utils.constants import TEST_RESOURCES_PATH + if is_win(): from ctypes import cdll diff --git a/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py b/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py index 815a9d10a..0254f3ce5 100644 --- a/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py @@ -23,10 +23,11 @@ Functional tests to test the PresentationController and PresentationDocument classes and related methods. """ -from unittest import TestCase import os +from unittest import TestCase +from unittest.mock import MagicMock, mock_open, patch + from openlp.plugins.presentations.lib.presentationcontroller import PresentationController, PresentationDocument -from tests.functional import MagicMock, mock_open, patch FOLDER_TO_PATCH = 'openlp.plugins.presentations.lib.presentationcontroller.PresentationDocument.get_thumbnail_folder' diff --git a/tests/functional/openlp_plugins/remotes/test_remotetab.py b/tests/functional/openlp_plugins/remotes/test_remotetab.py index 2dfd41aa3..27ed8a24e 100644 --- a/tests/functional/openlp_plugins/remotes/test_remotetab.py +++ b/tests/functional/openlp_plugins/remotes/test_remotetab.py @@ -25,13 +25,13 @@ This module contains tests for the lib submodule of the Remotes plugin. import os import re from unittest import TestCase +from unittest.mock import patch from PyQt5 import QtWidgets - from openlp.core.common import Settings from openlp.plugins.remotes.lib.remotetab import RemoteTab -from tests.functional import patch + from tests.helpers.testmixin import TestMixin __default_settings__ = { diff --git a/tests/functional/openlp_plugins/songs/test_chordproimport.py b/tests/functional/openlp_plugins/songs/test_chordproimport.py index fbf622d3c..b096fcb15 100644 --- a/tests/functional/openlp_plugins/songs/test_chordproimport.py +++ b/tests/functional/openlp_plugins/songs/test_chordproimport.py @@ -25,7 +25,7 @@ This module contains tests for the OpenSong song importer. import os from tests.helpers.songfileimport import SongImportTestHelper -from tests.functional import patch, MagicMock +from unittest.mock import patch, MagicMock TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'chordprosongs')) diff --git a/tests/functional/openlp_plugins/songs/test_editsongform.py b/tests/functional/openlp_plugins/songs/test_editsongform.py index 5ff0a633c..bb5120f7d 100644 --- a/tests/functional/openlp_plugins/songs/test_editsongform.py +++ b/tests/functional/openlp_plugins/songs/test_editsongform.py @@ -23,6 +23,7 @@ This module contains tests for the lib submodule of the Songs plugin. """ from unittest import TestCase +from unittest.mock import patch, MagicMock from PyQt5 import QtCore @@ -30,7 +31,7 @@ from openlp.core.common import Registry, Settings from openlp.core.lib import ServiceItem from openlp.plugins.songs.forms.editsongform import EditSongForm from openlp.plugins.songs.lib.db import AuthorType -from tests.functional import patch, MagicMock + from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_plugins/songs/test_editverseform.py b/tests/functional/openlp_plugins/songs/test_editverseform.py index 96ce672df..0cb08e827 100644 --- a/tests/functional/openlp_plugins/songs/test_editverseform.py +++ b/tests/functional/openlp_plugins/songs/test_editverseform.py @@ -23,14 +23,12 @@ This module contains tests for the editverseform of the Songs plugin. """ from unittest import TestCase +from unittest.mock import MagicMock -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore -from openlp.core.common import Registry, Settings -from openlp.core.lib import ServiceItem from openlp.plugins.songs.forms.editverseform import EditVerseForm -from openlp.plugins.songs.lib.db import AuthorType -from tests.functional import patch, MagicMock + from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_plugins/songs/test_ewimport.py b/tests/functional/openlp_plugins/songs/test_ewimport.py index f8ab2a61c..9427cf815 100644 --- a/tests/functional/openlp_plugins/songs/test_ewimport.py +++ b/tests/functional/openlp_plugins/songs/test_ewimport.py @@ -22,11 +22,9 @@ """ This module contains tests for the EasyWorship song importer. """ - import os from unittest import TestCase - -from tests.functional import MagicMock, patch +from unittest.mock import MagicMock, patch from openlp.core.common import Registry from openlp.plugins.songs.lib.importers.easyworship import EasyWorshipSongImport, FieldDescEntry, FieldType diff --git a/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py b/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py index cd7c5d047..1a8b1e38b 100644 --- a/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py +++ b/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py @@ -22,10 +22,9 @@ """ This module contains tests for the SongShow Plus song importer. """ - import os from unittest import TestCase -from tests.functional import patch, MagicMock +from unittest.mock import patch, MagicMock from openlp.plugins.songs.lib.importers.foilpresenter import FoilPresenter diff --git a/tests/functional/openlp_plugins/songs/test_lib.py b/tests/functional/openlp_plugins/songs/test_lib.py index d19c29e1b..d1cb22908 100644 --- a/tests/functional/openlp_plugins/songs/test_lib.py +++ b/tests/functional/openlp_plugins/songs/test_lib.py @@ -23,10 +23,10 @@ This module contains tests for the lib submodule of the Songs plugin. """ from unittest import TestCase +from unittest.mock import patch, MagicMock, PropertyMock from openlp.plugins.songs.lib import VerseType, clean_string, clean_title, strip_rtf, transpose_chord, transpose_lyrics from openlp.plugins.songs.lib.songcompare import songs_probably_equal, _remove_typos, _op_length -from tests.functional import patch, MagicMock, PropertyMock class TestLib(TestCase): diff --git a/tests/functional/openlp_plugins/songs/test_lyriximport.py b/tests/functional/openlp_plugins/songs/test_lyriximport.py index b81cc7ce8..32644e033 100644 --- a/tests/functional/openlp_plugins/songs/test_lyriximport.py +++ b/tests/functional/openlp_plugins/songs/test_lyriximport.py @@ -21,14 +21,10 @@ """ This module contains tests for the LyriX song importer. """ - import os -from unittest import TestCase +from unittest.mock import patch from tests.helpers.songfileimport import SongImportTestHelper -from openlp.plugins.songs.lib.importers.opensong import OpenSongImport -from openlp.core.common import Registry -from tests.functional import patch, MagicMock TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'lyrixsongs')) diff --git a/tests/functional/openlp_plugins/songs/test_mediaitem.py b/tests/functional/openlp_plugins/songs/test_mediaitem.py index 8182bdff4..d5b06b7dc 100644 --- a/tests/functional/openlp_plugins/songs/test_mediaitem.py +++ b/tests/functional/openlp_plugins/songs/test_mediaitem.py @@ -23,15 +23,15 @@ This module contains tests for the lib submodule of the Songs plugin. """ from unittest import TestCase -from unittest.mock import call +from unittest.mock import MagicMock, patch, call from PyQt5 import QtCore from openlp.core.common import Registry, Settings from openlp.core.lib import ServiceItem -from openlp.plugins.songs.lib.mediaitem import SongMediaItem from openlp.plugins.songs.lib.db import AuthorType, Song -from tests.functional import patch, MagicMock +from openlp.plugins.songs.lib.mediaitem import SongMediaItem + from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_plugins/songs/test_mediashout.py b/tests/functional/openlp_plugins/songs/test_mediashout.py index e2c080652..7e828df89 100644 --- a/tests/functional/openlp_plugins/songs/test_mediashout.py +++ b/tests/functional/openlp_plugins/songs/test_mediashout.py @@ -22,8 +22,9 @@ """ Test the MediaShout importer """ -from unittest import TestCase, skipUnless from collections import namedtuple +from unittest import TestCase, skipUnless +from unittest.mock import MagicMock, patch, call from openlp.core.common import Registry try: @@ -32,8 +33,6 @@ try: except ImportError: CAN_RUN_TESTS = False -from tests.functional import MagicMock, patch, call - @skipUnless(CAN_RUN_TESTS, 'Not Windows, skipping test') class TestMediaShoutImport(TestCase): diff --git a/tests/functional/openlp_plugins/songs/test_openlpimporter.py b/tests/functional/openlp_plugins/songs/test_openlpimporter.py index 0af67e7b2..70eda660a 100644 --- a/tests/functional/openlp_plugins/songs/test_openlpimporter.py +++ b/tests/functional/openlp_plugins/songs/test_openlpimporter.py @@ -23,10 +23,10 @@ This module contains tests for the OpenLP song importer. """ from unittest import TestCase +from unittest.mock import patch, MagicMock -from openlp.plugins.songs.lib.importers.openlp import OpenLPSongImport from openlp.core.common import Registry -from tests.functional import patch, MagicMock +from openlp.plugins.songs.lib.importers.openlp import OpenLPSongImport class TestOpenLPImport(TestCase): diff --git a/tests/functional/openlp_plugins/songs/test_openlyricsexport.py b/tests/functional/openlp_plugins/songs/test_openlyricsexport.py index cd7f69a17..bf74ec02b 100644 --- a/tests/functional/openlp_plugins/songs/test_openlyricsexport.py +++ b/tests/functional/openlp_plugins/songs/test_openlyricsexport.py @@ -22,17 +22,17 @@ """ This module contains tests for the OpenLyrics song importer. """ - import os import shutil -from unittest import TestCase from tempfile import mkdtemp +from unittest import TestCase +from unittest.mock import MagicMock, patch -from tests.functional import MagicMock, patch -from tests.helpers.testmixin import TestMixin from openlp.plugins.songs.lib.openlyricsexport import OpenLyricsExport from openlp.core.common import Registry +from tests.helpers.testmixin import TestMixin + class TestOpenLyricsExport(TestCase, TestMixin): """ diff --git a/tests/functional/openlp_plugins/songs/test_openlyricsimport.py b/tests/functional/openlp_plugins/songs/test_openlyricsimport.py index d7e274018..b87ee988c 100644 --- a/tests/functional/openlp_plugins/songs/test_openlyricsimport.py +++ b/tests/functional/openlp_plugins/songs/test_openlyricsimport.py @@ -22,19 +22,19 @@ """ This module contains tests for the OpenLyrics song importer. """ - import os import json from unittest import TestCase +from unittest.mock import MagicMock, patch + from lxml import etree, objectify -from tests.functional import MagicMock, patch -from tests.helpers.testmixin import TestMixin from openlp.plugins.songs.lib.importers.openlyrics import OpenLyricsImport from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.plugins.songs.lib.openlyricsxml import OpenLyrics from openlp.core.common import Registry, Settings +from tests.helpers.testmixin import TestMixin TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'openlyricssongs')) diff --git a/tests/functional/openlp_plugins/songs/test_openoffice.py b/tests/functional/openlp_plugins/songs/test_openoffice.py index 305ef8638..b276078d4 100644 --- a/tests/functional/openlp_plugins/songs/test_openoffice.py +++ b/tests/functional/openlp_plugins/songs/test_openoffice.py @@ -23,6 +23,7 @@ This module contains tests for the OpenOffice/LibreOffice importer. """ from unittest import TestCase, SkipTest +from unittest.mock import MagicMock, patch from openlp.core.common import Registry try: @@ -30,7 +31,6 @@ try: except ImportError: raise SkipTest('Could not import OpenOfficeImport probably due to unavailability of uno') -from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/openlp_plugins/songs/test_opensongimport.py b/tests/functional/openlp_plugins/songs/test_opensongimport.py index d6cec189a..2b67e8f19 100644 --- a/tests/functional/openlp_plugins/songs/test_opensongimport.py +++ b/tests/functional/openlp_plugins/songs/test_opensongimport.py @@ -24,12 +24,12 @@ This module contains tests for the OpenSong song importer. """ import os from unittest import TestCase +from unittest.mock import patch, MagicMock -from openlp.plugins.songs.lib.importers.opensong import OpenSongImport from openlp.core.common import Registry +from openlp.plugins.songs.lib.importers.opensong import OpenSongImport from tests.helpers.songfileimport import SongImportTestHelper -from tests.functional import patch, MagicMock TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'opensongsongs')) diff --git a/tests/functional/openlp_plugins/songs/test_opsproimport.py b/tests/functional/openlp_plugins/songs/test_opsproimport.py index f480c141b..7042bdb9e 100644 --- a/tests/functional/openlp_plugins/songs/test_opsproimport.py +++ b/tests/functional/openlp_plugins/songs/test_opsproimport.py @@ -25,6 +25,7 @@ This module contains tests for the WorshipCenter Pro song importer. import os import json from unittest import TestCase, skipUnless +from unittest.mock import patch, MagicMock try: from openlp.core.common import Registry @@ -33,8 +34,6 @@ try: except ImportError: CAN_RUN_TESTS = False -from tests.functional import patch, MagicMock - TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'opsprosongs')) diff --git a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py index 3291b6b0c..fc44cf97f 100644 --- a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py +++ b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py @@ -22,15 +22,15 @@ """ This module contains tests for the Songbeamer song importer. """ - import os from unittest import TestCase +from unittest.mock import MagicMock, patch -from tests.helpers.songfileimport import SongImportTestHelper -from tests.functional import MagicMock, patch from openlp.plugins.songs.lib.importers.songbeamer import SongBeamerImport, SongBeamerTypes from openlp.core.common import Registry +from tests.helpers.songfileimport import SongImportTestHelper + TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'songbeamersongs')) diff --git a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py index 0579f6b11..e7dd5d354 100644 --- a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py +++ b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py @@ -22,14 +22,14 @@ """ This module contains tests for the SongShow Plus song importer. """ - import os from unittest import TestCase +from unittest.mock import patch, MagicMock -from tests.helpers.songfileimport import SongImportTestHelper from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib.importers.songshowplus import SongShowPlusImport -from tests.functional import patch, MagicMock + +from tests.helpers.songfileimport import SongImportTestHelper TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'songshowplussongs')) diff --git a/tests/functional/openlp_plugins/songs/test_sundayplusimport.py b/tests/functional/openlp_plugins/songs/test_sundayplusimport.py index a50bf7b01..9c6ef1a42 100644 --- a/tests/functional/openlp_plugins/songs/test_sundayplusimport.py +++ b/tests/functional/openlp_plugins/songs/test_sundayplusimport.py @@ -19,13 +19,12 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -This module contains tests for the VideoPsalm song importer. +This module contains tests for the SundayPlus song importer. """ - import os +from unittest.mock import patch from tests.helpers.songfileimport import SongImportTestHelper -from tests.functional import patch TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'sundayplussongs')) diff --git a/tests/functional/openlp_plugins/songs/test_videopsalm.py b/tests/functional/openlp_plugins/songs/test_videopsalm.py index 6fb236bfb..c3e2a276f 100644 --- a/tests/functional/openlp_plugins/songs/test_videopsalm.py +++ b/tests/functional/openlp_plugins/songs/test_videopsalm.py @@ -25,7 +25,7 @@ This module contains tests for the VideoPsalm song importer. import os from tests.helpers.songfileimport import SongImportTestHelper -from tests.functional import patch, MagicMock +from unittest.mock import patch, MagicMock TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'videopsalmsongs')) diff --git a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py index 76867c37d..fd39b80f9 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py @@ -23,6 +23,7 @@ This module contains tests for the WorshipCenter Pro song importer. """ from unittest import TestCase, skipUnless +from unittest.mock import patch, MagicMock try: import pyodbc @@ -33,9 +34,6 @@ except ImportError: CAN_RUN_TESTS = False -from tests.functional import patch, MagicMock - - class TestRecord(object): """ Microsoft Access Driver is not available on non Microsoft Systems for this reason the :class:`TestRecord` is used diff --git a/tests/functional/openlp_plugins/songs/test_zionworximport.py b/tests/functional/openlp_plugins/songs/test_zionworximport.py index ccfaa4154..97c1e8fa2 100644 --- a/tests/functional/openlp_plugins/songs/test_zionworximport.py +++ b/tests/functional/openlp_plugins/songs/test_zionworximport.py @@ -23,15 +23,15 @@ This module contains tests for the ZionWorx song importer. """ import os - from unittest import TestCase +from unittest.mock import MagicMock, patch -from tests.functional import MagicMock, patch -from tests.helpers.songfileimport import SongImportTestHelper from openlp.plugins.songs.lib.importers.zionworx import ZionWorxImport from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.core.common import Registry +from tests.helpers.songfileimport import SongImportTestHelper + TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'zionworxsongs')) diff --git a/tests/functional/test_init.py b/tests/functional/test_init.py index c4560d321..4cb6e5a76 100644 --- a/tests/functional/test_init.py +++ b/tests/functional/test_init.py @@ -24,6 +24,7 @@ Package to test the openlp.core.__init__ package. """ import os from unittest import TestCase +from unittest.mock import MagicMock, patch, call from PyQt5 import QtCore, QtWidgets @@ -31,7 +32,6 @@ from openlp.core import OpenLP, parse_options from openlp.core.common import Settings from tests.helpers.testmixin import TestMixin -from tests.functional import MagicMock, patch, call TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'resources')) diff --git a/tests/helpers/songfileimport.py b/tests/helpers/songfileimport.py index 909edb621..08453e0b2 100644 --- a/tests/helpers/songfileimport.py +++ b/tests/helpers/songfileimport.py @@ -26,11 +26,10 @@ song files from third party applications. import json import logging from unittest import TestCase +from unittest.mock import MagicMock, patch, call -from openlp.plugins.songs.lib.importers.opensong import OpenSongImport from openlp.core.common import Registry - -from tests.functional import patch, MagicMock, call +from openlp.plugins.songs.lib.importers.opensong import OpenSongImport log = logging.getLogger(__name__) diff --git a/tests/interfaces/__init__.py b/tests/interfaces/__init__.py index 1b5acc94c..14e1634ea 100644 --- a/tests/interfaces/__init__.py +++ b/tests/interfaces/__init__.py @@ -19,9 +19,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import sys - -if sys.version_info[1] >= 3: - from unittest.mock import patch, MagicMock -else: - from mock import patch, MagicMock +""" +Interface tests +""" diff --git a/tests/interfaces/openlp_core_lib/test_pluginmanager.py b/tests/interfaces/openlp_core_lib/test_pluginmanager.py index 7ad9822b0..39e964143 100644 --- a/tests/interfaces/openlp_core_lib/test_pluginmanager.py +++ b/tests/interfaces/openlp_core_lib/test_pluginmanager.py @@ -27,12 +27,13 @@ import shutil import gc from tempfile import mkdtemp from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtWidgets from openlp.core.common import Registry, Settings from openlp.core.lib.pluginmanager import PluginManager -from tests.interfaces import MagicMock, patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py index 30a9b8ef7..c2d5e192f 100644 --- a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py +++ b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py @@ -23,12 +23,13 @@ Package to test the openlp.core.ui package. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtTest, QtWidgets from openlp.core.common import Registry from openlp.core.ui import filerenameform -from tests.interfaces import MagicMock, patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_core_ui/test_mainwindow.py b/tests/interfaces/openlp_core_ui/test_mainwindow.py index 6e4f8d9ed..1bff8477c 100644 --- a/tests/interfaces/openlp_core_ui/test_mainwindow.py +++ b/tests/interfaces/openlp_core_ui/test_mainwindow.py @@ -23,11 +23,11 @@ Package to test the openlp.core.ui.mainwindow package. """ from unittest import TestCase - +from unittest.mock import MagicMock, patch from openlp.core.common import Registry from openlp.core.ui.mainwindow import MainWindow -from tests.interfaces import MagicMock, patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_core_ui/test_projectoreditform.py b/tests/interfaces/openlp_core_ui/test_projectoreditform.py index a8ec950f3..8e1758b31 100644 --- a/tests/interfaces/openlp_core_ui/test_projectoreditform.py +++ b/tests/interfaces/openlp_core_ui/test_projectoreditform.py @@ -25,12 +25,12 @@ class and methods. """ import os from unittest import TestCase +from unittest.mock import patch from openlp.core.common import Registry from openlp.core.lib.projector.db import Projector, ProjectorDB from openlp.core.ui import ProjectorEditForm -from tests.functional import patch from tests.helpers.testmixin import TestMixin from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA diff --git a/tests/interfaces/openlp_core_ui/test_projectormanager.py b/tests/interfaces/openlp_core_ui/test_projectormanager.py index d549de394..96bbe4a4c 100644 --- a/tests/interfaces/openlp_core_ui/test_projectormanager.py +++ b/tests/interfaces/openlp_core_ui/test_projectormanager.py @@ -24,14 +24,13 @@ Interface tests to test the themeManager class and related methods. """ import os from unittest import TestCase +from unittest.mock import patch, MagicMock from openlp.core.common import Registry, Settings -from tests.functional import patch, MagicMock -from tests.helpers.testmixin import TestMixin - from openlp.core.ui import ProjectorManager, ProjectorEditForm from openlp.core.lib.projector.db import Projector, ProjectorDB +from tests.helpers.testmixin import TestMixin from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA, TEST3_DATA diff --git a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py index a2617740e..27fa04348 100644 --- a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py +++ b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py @@ -24,24 +24,21 @@ Tests for the Projector Source Select form. """ -import logging -log = logging.getLogger(__name__) -log.debug('test_projectorsourceform loaded') import os import time from unittest import TestCase +from unittest.mock import patch from PyQt5.QtWidgets import QDialog -from tests.functional import patch -from tests.helpers.testmixin import TestMixin -from tests.resources.projector.data import TEST_DB, TEST1_DATA - from openlp.core.common import Registry, Settings from openlp.core.lib.projector.db import ProjectorDB, Projector from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle +from tests.helpers.testmixin import TestMixin +from tests.resources.projector.data import TEST_DB, TEST1_DATA + def build_source_dict(): """ diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index 22e4f1f67..10e928bc2 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -22,13 +22,13 @@ """ Package to test the openlp.core.lib package. """ - from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core.common import Registry from openlp.core.lib import ScreenList, ServiceItem, ItemCapabilities from openlp.core.ui.mainwindow import MainWindow -from tests.interfaces import MagicMock, patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py index 570fd93fe..82d56bca9 100644 --- a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py +++ b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py @@ -23,12 +23,13 @@ Package to test the openlp.core.ui package. """ from unittest import TestCase +from unittest.mock import patch from PyQt5 import QtCore, QtTest, QtWidgets from openlp.core.common import Registry from openlp.core.ui import servicenoteform -from tests.interfaces import patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_core_ui/test_settings_form.py b/tests/interfaces/openlp_core_ui/test_settings_form.py index 3aaaeec71..d78de3eb5 100644 --- a/tests/interfaces/openlp_core_ui/test_settings_form.py +++ b/tests/interfaces/openlp_core_ui/test_settings_form.py @@ -23,13 +23,14 @@ Package to test the openlp.core.lib.settingsform package. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtCore, QtTest from openlp.core.common import Registry from openlp.core.ui import settingsform from openlp.core.lib import ScreenList -from tests.interfaces import MagicMock, patch + from tests.helpers.testmixin import TestMixin SCREEN = { diff --git a/tests/interfaces/openlp_core_ui/test_shortcutlistform.py b/tests/interfaces/openlp_core_ui/test_shortcutlistform.py index 8cbbb43f2..dfea62b0c 100644 --- a/tests/interfaces/openlp_core_ui/test_shortcutlistform.py +++ b/tests/interfaces/openlp_core_ui/test_shortcutlistform.py @@ -23,13 +23,13 @@ Package to test the openlp.core.ui.shortcutform package. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry from openlp.core.ui.shortcutlistform import ShortcutListForm -from tests.interfaces import MagicMock, patch from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_core_ui/test_starttimedialog.py b/tests/interfaces/openlp_core_ui/test_starttimedialog.py index db8784cb9..d754d9e51 100644 --- a/tests/interfaces/openlp_core_ui/test_starttimedialog.py +++ b/tests/interfaces/openlp_core_ui/test_starttimedialog.py @@ -23,12 +23,13 @@ Package to test the openlp.core.ui package. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtCore, QtTest, QtWidgets from openlp.core.common import Registry from openlp.core.ui import starttimeform -from tests.interfaces import MagicMock, patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_core_ui/test_thememanager.py b/tests/interfaces/openlp_core_ui/test_thememanager.py index d36d8d7e2..b560df154 100644 --- a/tests/interfaces/openlp_core_ui/test_thememanager.py +++ b/tests/interfaces/openlp_core_ui/test_thememanager.py @@ -23,10 +23,11 @@ Interface tests to test the themeManager class and related methods. """ from unittest import TestCase +from unittest.mock import patch, MagicMock from openlp.core.common import Registry, Settings from openlp.core.ui import ThemeManager, ThemeForm, FileRenameForm -from tests.functional import patch, MagicMock + from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_core_ui_lib/test_listpreviewwidget.py b/tests/interfaces/openlp_core_ui_lib/test_listpreviewwidget.py index 2ac316436..87eb9660d 100644 --- a/tests/interfaces/openlp_core_ui_lib/test_listpreviewwidget.py +++ b/tests/interfaces/openlp_core_ui_lib/test_listpreviewwidget.py @@ -22,15 +22,15 @@ """ Package to test the openlp.core.ui.lib.listpreviewwidget. """ - from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtGui, QtWidgets from openlp.core.common import Registry from openlp.core.lib import ServiceItem from openlp.core.ui.lib import ListWidgetWithDnD, ListPreviewWidget -from tests.interfaces import MagicMock, patch + from tests.utils.osdinteraction import read_service_from_file from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py b/tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py index a7bf3c562..733774e1e 100644 --- a/tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py +++ b/tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py @@ -28,12 +28,11 @@ from unittest.mock import MagicMock, patch from PyQt5 import QtWidgets from openlp.core.common import Registry -from openlp.plugins.bibles.forms.bibleimportform import BibleImportForm, PYSWORD_AVAILABLE +from openlp.plugins.bibles.forms import bibleimportform from tests.helpers.testmixin import TestMixin -@skip('One of the QFormLayouts in the BibleImportForm is causing a segfault') class TestBibleImportForm(TestCase, TestMixin): """ Test the BibleImportForm class @@ -47,9 +46,9 @@ class TestBibleImportForm(TestCase, TestMixin): self.setup_application() self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) - PYSWORD_AVAILABLE = False + bibleimportform.PYSWORD_AVAILABLE = False self.mocked_manager = MagicMock() - self.form = BibleImportForm(self.main_window, self.mocked_manager, MagicMock()) + self.form = bibleimportform.BibleImportForm(self.main_window, self.mocked_manager, MagicMock()) def tearDown(self): """ diff --git a/tests/interfaces/openlp_plugins/bibles/test_lib_http.py b/tests/interfaces/openlp_plugins/bibles/test_lib_http.py index 3f77735a8..e4075ca19 100644 --- a/tests/interfaces/openlp_plugins/bibles/test_lib_http.py +++ b/tests/interfaces/openlp_plugins/bibles/test_lib_http.py @@ -23,10 +23,10 @@ Package to test the openlp.plugin.bible.lib.https package. """ from unittest import TestCase, skip +from unittest.mock import MagicMock from openlp.core.common import Registry from openlp.plugins.bibles.lib.importers.http import BGExtract, CWExtract, BSExtract -from tests.interfaces import MagicMock class TestBibleHTTP(TestCase): diff --git a/tests/interfaces/openlp_plugins/bibles/test_lib_manager.py b/tests/interfaces/openlp_plugins/bibles/test_lib_manager.py index 2166dda40..6582b123f 100644 --- a/tests/interfaces/openlp_plugins/bibles/test_lib_manager.py +++ b/tests/interfaces/openlp_plugins/bibles/test_lib_manager.py @@ -23,10 +23,10 @@ Functional tests to test the Bible Manager class and related methods. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from openlp.core.common import Registry, Settings from openlp.plugins.bibles.lib import BibleManager, LanguageSelection -from tests.interfaces import MagicMock, patch from tests.utils.constants import TEST_RESOURCES_PATH from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py b/tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py index b6fed9f3a..95f0be3b5 100644 --- a/tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py +++ b/tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py @@ -23,7 +23,7 @@ This module contains tests for the lib submodule of the Bibles plugin. """ from unittest import TestCase -from tests.interfaces import MagicMock, patch +from unittest.mock import MagicMock, patch from openlp.core.common import Registry, Settings from openlp.plugins.bibles.lib import BibleManager, parse_reference, LanguageSelection diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py index 38bc6f255..73d8673db 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py @@ -23,14 +23,14 @@ Module to test the EditCustomForm. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtTest, QtCore, QtWidgets from openlp.core.common import Registry -# TODO: FIXME: Import needed due to horrible bad imports from openlp.plugins.custom.lib.mediaitem import CustomMediaItem from openlp.plugins.custom.forms.editcustomform import EditCustomForm -from tests.interfaces import MagicMock, patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py index 7d833149e..5284fdde5 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py @@ -23,12 +23,13 @@ Module to test the EditCustomSlideForm. """ from unittest import TestCase +from unittest.mock import MagicMock, patch from PyQt5 import QtWidgets from openlp.core.common import Registry from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm -from tests.interfaces import MagicMock, patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py b/tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py index b80dda2ff..4b06f6b03 100644 --- a/tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py +++ b/tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py @@ -22,9 +22,10 @@ """ Module to test the MediaClipSelectorForm. """ - import os from unittest import TestCase, SkipTest +from unittest.mock import MagicMock, patch + from openlp.core.ui.media.vlcplayer import get_vlc if os.name == 'nt' and not get_vlc(): @@ -34,7 +35,7 @@ from PyQt5 import QtTest, QtCore, QtWidgets from openlp.core.common import Registry from openlp.plugins.media.forms.mediaclipselectorform import MediaClipSelectorForm -from tests.interfaces import MagicMock, patch + from tests.helpers.testmixin import TestMixin diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py b/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py index 6091674a9..b82bb29ae 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py @@ -23,13 +23,14 @@ Package to test the openlp.plugins.songs.forms.editsongform package. """ from unittest import TestCase +from unittest.mock import MagicMock from PyQt5 import QtWidgets from openlp.core.common import Registry from openlp.core.common.uistrings import UiStrings from openlp.plugins.songs.forms.editsongform import EditSongForm -from tests.interfaces import MagicMock + from tests.helpers.testmixin import TestMixin