From b0b80649d4716daf62a30f9b77479642959c0780 Mon Sep 17 00:00:00 2001 From: Phill Ridout Date: Sat, 9 Dec 2017 08:22:14 +0000 Subject: [PATCH 1/4] Service maganger fix --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 29718e09a..875a48fdf 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -370,7 +370,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi :rtype: None """ self._service_path = file_path - self.main_window.set_service_modified(self.is_modified(), file_path.name) + self.set_modified(self.is_modified()) Settings().setValue('servicemanager/last file', file_path) if file_path and file_path.suffix == '.oszl': self._save_lite = True From 8717d6218845511d77a7bdfbb2e9551d270dddf8 Mon Sep 17 00:00:00 2001 From: Phill Ridout Date: Sun, 17 Dec 2017 15:23:38 +0000 Subject: [PATCH 2/4] Set word wrap on SWORD importer info label Fixes: https://launchpad.net/bugs/1736274 --- openlp/plugins/bibles/forms/bibleimportform.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 35dd82eeb..857c48f74 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -336,6 +336,7 @@ class BibleImportForm(OpenLPWizard): self.sword_layout.addWidget(self.sword_tab_widget) self.sword_disabled_label = QtWidgets.QLabel(self.sword_widget) self.sword_disabled_label.setObjectName('SwordDisabledLabel') + self.sword_disabled_label.setWordWrap(True) self.sword_layout.addWidget(self.sword_disabled_label) self.select_stack.addWidget(self.sword_widget) self.wordproject_widget = QtWidgets.QWidget(self.select_page) From 370ec244d833b849f48c76100da0c8d73c821a09 Mon Sep 17 00:00:00 2001 From: Phill Ridout Date: Sun, 17 Dec 2017 15:25:54 +0000 Subject: [PATCH 3/4] Fix osx finding 'temp' files instead of the python source files Fixes: https://launchpad.net/bugs/1738047 --- openlp/core/common/__init__.py | 1 + openlp/core/lib/pluginmanager.py | 2 +- openlp/core/ui/media/mediacontroller.py | 3 ++- openlp/plugins/presentations/presentationplugin.py | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openlp/core/common/__init__.py b/openlp/core/common/__init__.py index 99e222041..b6d759f42 100644 --- a/openlp/core/common/__init__.py +++ b/openlp/core/common/__init__.py @@ -80,6 +80,7 @@ def extension_loader(glob_pattern, excluded_files=[]): extension_path = extension_path.relative_to(app_dir) if extension_path.name in excluded_files: continue + log.debug('Attempting to import %s', extension_path) module_name = path_to_module(extension_path) try: importlib.import_module(module_name) diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index d4a02f8c0..c82e26eec 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -71,7 +71,7 @@ class PluginManager(RegistryBase, LogMixin, RegistryProperties): """ Scan a directory for objects inheriting from the ``Plugin`` class. """ - glob_pattern = os.path.join('plugins', '*', '*plugin.py') + glob_pattern = os.path.join('plugins', '*', '[!.]*plugin.py') extension_loader(glob_pattern) plugin_classes = Plugin.__subclasses__() plugin_objects = [] diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 10c384b0c..87d3a3063 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -181,7 +181,8 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): """ log.debug('_check_available_media_players') controller_dir = os.path.join('core', 'ui', 'media') - glob_pattern = os.path.join(controller_dir, '*player.py') + # Find all files that do not begin with '.' (lp:#1738047) and end with player.py + glob_pattern = os.path.join(controller_dir, '[!.]*player.py') extension_loader(glob_pattern, ['mediaplayer.py']) player_classes = MediaPlayer.__subclasses__() for player_class in player_classes: diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index a68a22176..c65971f11 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -129,7 +129,8 @@ class PresentationPlugin(Plugin): """ log.debug('check_pre_conditions') controller_dir = os.path.join('plugins', 'presentations', 'lib') - glob_pattern = os.path.join(controller_dir, '*controller.py') + # Find all files that do not begin with '.' (lp:#1738047) and end with controller.py + glob_pattern = os.path.join(controller_dir, '[!.]*controller.py') extension_loader(glob_pattern, ['presentationcontroller.py']) controller_classes = PresentationController.__subclasses__() for controller_class in controller_classes: From e9f4637895557615689b33eac247de2ac419644d Mon Sep 17 00:00:00 2001 From: Phill Ridout Date: Sun, 17 Dec 2017 15:28:21 +0000 Subject: [PATCH 4/4] Impress tests --- .../presentations/test_impresscontroller.py | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/tests/functional/openlp_plugins/presentations/test_impresscontroller.py b/tests/functional/openlp_plugins/presentations/test_impresscontroller.py index f08e0b8ac..9e15a0c79 100644 --- a/tests/functional/openlp_plugins/presentations/test_impresscontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_impresscontroller.py @@ -23,7 +23,7 @@ Functional tests to test the Impress class and related methods. """ from unittest import TestCase -from unittest.mock import MagicMock +from unittest.mock import MagicMock, patch import shutil from tempfile import mkdtemp @@ -72,6 +72,60 @@ class TestImpressController(TestCase, TestMixin): self.assertEqual('Impress', controller.name, 'The name of the presentation controller should be correct') + @patch('openlp.plugins.presentations.lib.impresscontroller.log') + def test_check_available(self, mocked_log): + """ + Test `ImpressController.check_available` on Windows + """ + # GIVEN: An instance of :class:`ImpressController` + controller = ImpressController(plugin=self.mock_plugin) + + # WHEN: `check_available` is called on Windows and `get_com_servicemanager` returns None + with patch('openlp.plugins.presentations.lib.impresscontroller.is_win', return_value=True), \ + patch.object(controller, 'get_com_servicemanager', return_value=None) as mocked_get_com_servicemanager: + result = controller.check_available() + + # THEN: `check_available` should return False + assert mocked_get_com_servicemanager.called is True + assert result is False + + @patch('openlp.plugins.presentations.lib.impresscontroller.log') + def test_check_available1(self, mocked_log): + """ + Test `ImpressController.check_available` on Windows + """ + # GIVEN: An instance of :class:`ImpressController` + controller = ImpressController(plugin=self.mock_plugin) + + # WHEN: `check_available` is called on Windows and `get_com_servicemanager` returns an object + mocked_com_object = MagicMock() + with patch('openlp.plugins.presentations.lib.impresscontroller.is_win', return_value=True), \ + patch.object(controller, 'get_com_servicemanager', return_value=mocked_com_object) \ + as mocked_get_com_servicemanager: + result = controller.check_available() + + # THEN: `check_available` should return True + assert mocked_get_com_servicemanager.called is True + assert result is True + + @patch('openlp.plugins.presentations.lib.impresscontroller.log') + @patch('openlp.plugins.presentations.lib.impresscontroller.is_win', return_value=False) + def test_check_available2(self, mocked_is_win, mocked_log): + """ + Test `ImpressController.check_available` when not on Windows + """ + # GIVEN: An instance of :class:`ImpressController` + controller = ImpressController(plugin=self.mock_plugin) + + # WHEN: `check_available` is called on Windows and `uno_available` is True + with patch('openlp.plugins.presentations.lib.impresscontroller.uno_available', True), \ + patch.object(controller, 'get_com_servicemanager') as mocked_get_com_servicemanager: + result = controller.check_available() + + # THEN: `check_available` should return True + assert mocked_get_com_servicemanager.called is False + assert result is True + class TestImpressDocument(TestCase): """