diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 7324d0fbe..0f66e1533 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -397,7 +397,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage if not suffix in self.suffixes: self.suffixes.append(suffix) - def on_new_service_clicked(self): + def on_new_service_clicked(self, field=None): """ Create a new service. """ @@ -861,7 +861,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage theme_action.setChecked(True) self.menu.exec_(self.service_manager_list.mapToGlobal(point)) - def on_service_item_note_form(self): + def on_service_item_note_form(self, field=None): """ Allow the service note to be edited """ @@ -872,7 +872,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage self.repaint_service_list(item, -1) self.set_modified() - def on_start_time_form(self): + def on_start_time_form(self, field=None): """ Opens a dialog to type in service item notes. """ @@ -911,7 +911,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage self.main_window.general_settings_section + '/loop delay') self.set_modified() - def on_timed_slide_interval(self): + def on_timed_slide_interval(self, field=None): """ Shows input dialog for enter interval in seconds for delay """ @@ -944,7 +944,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage self.service_items[item]['service_item'].will_auto_start = \ not self.service_items[item]['service_item'].will_auto_start - def on_service_item_edit_form(self): + def on_service_item_edit_form(self, field=None): """ Opens a dialog to edit the service item and update the service display if changes are saved. """ @@ -1024,7 +1024,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage prev_item_last_slide = service_iterator.value() service_iterator += 1 - def on_set_item(self, message): + def on_set_item(self, message, field=None): """ Called by a signal to select a specific item and make it live usually from remote. """ @@ -1137,7 +1137,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage self.repaint_service_list(len(self.service_items) - 1, child) self.set_modified() - def on_delete_from_service(self): + def on_delete_from_service(self, field=None): """ Remove the current ServiceItem from the list. """ diff --git a/tests/functional/openlp_core_lib/test_pluginmanager.py b/tests/functional/openlp_core_lib/test_pluginmanager.py index 66383548a..ce5c240b2 100644 --- a/tests/functional/openlp_core_lib/test_pluginmanager.py +++ b/tests/functional/openlp_core_lib/test_pluginmanager.py @@ -71,7 +71,7 @@ class TestPluginManager(TestCase): # THEN: The create_media_manager_item() method should have been called self.assertEqual(0, mocked_plugin.create_media_manager_item.call_count, - 'The create_media_manager_item() method should not have been called.') + 'The create_media_manager_item() method should not have been called.') def hook_media_manager_with_active_plugin_test(self): """ @@ -104,7 +104,7 @@ class TestPluginManager(TestCase): # THEN: The hook_settings_tabs() method should have been called self.assertEqual(0, mocked_plugin.create_media_manager_item.call_count, - 'The create_media_manager_item() method should not have been called.') + 'The create_media_manager_item() method should not have been called.') def hook_settings_tabs_with_disabled_plugin_and_mocked_form_test(self): """ @@ -124,9 +124,9 @@ class TestPluginManager(TestCase): # THEN: The create_settings_tab() method should not have been called, but the plugins lists should be the same self.assertEqual(0, mocked_plugin.create_settings_tab.call_count, - 'The create_media_manager_item() method should not have been called.') + 'The create_media_manager_item() method should not have been called.') self.assertEqual(mocked_settings_form.plugin_manager.plugins, plugin_manager.plugins, - 'The plugins on the settings form should be the same as the plugins in the plugin manager') + 'The plugins on the settings form should be the same as the plugins in the plugin manager') def hook_settings_tabs_with_active_plugin_and_mocked_form_test(self): """ @@ -146,9 +146,9 @@ class TestPluginManager(TestCase): # THEN: The create_media_manager_item() method should have been called with the mocked settings form self.assertEqual(1, mocked_plugin.create_settings_tab.call_count, - 'The create_media_manager_item() method should have been called once.') + 'The create_media_manager_item() method should have been called once.') self.assertEqual(plugin_manager.plugins, mocked_settings_form.plugin_manager.plugins, - 'The plugins on the settings form should be the same as the plugins in the plugin manager') + 'The plugins on the settings form should be the same as the plugins in the plugin manager') def hook_settings_tabs_with_active_plugin_and_no_form_test(self): """ @@ -181,7 +181,7 @@ class TestPluginManager(TestCase): # THEN: The create_media_manager_item() method should have been called self.assertEqual(0, mocked_plugin.add_import_menu_item.call_count, - 'The add_import_menu_item() method should not have been called.') + 'The add_import_menu_item() method should not have been called.') def hook_import_menu_with_active_plugin_test(self): """ @@ -214,7 +214,7 @@ class TestPluginManager(TestCase): # THEN: The add_export_menu_Item() method should not have been called self.assertEqual(0, mocked_plugin.add_export_menu_Item.call_count, - 'The add_export_menu_Item() method should not have been called.') + 'The add_export_menu_Item() method should not have been called.') def hook_export_menu_with_active_plugin_test(self): """ @@ -248,7 +248,7 @@ class TestPluginManager(TestCase): # THEN: The upgrade_settings() method should not have been called self.assertEqual(0, mocked_plugin.upgrade_settings.call_count, - 'The upgrade_settings() method should not have been called.') + 'The upgrade_settings() method should not have been called.') def hook_upgrade_plugin_settings_with_active_plugin_test(self): """ @@ -282,7 +282,7 @@ class TestPluginManager(TestCase): # THEN: The add_tools_menu_item() method should have been called self.assertEqual(0, mocked_plugin.add_tools_menu_item.call_count, - 'The add_tools_menu_item() method should not have been called.') + 'The add_tools_menu_item() method should not have been called.') def hook_tools_menu_with_active_plugin_test(self): """ diff --git a/tests/functional/openlp_core_lib/test_screen.py b/tests/functional/openlp_core_lib/test_screen.py index b9e7fb5e0..bf4bf7263 100644 --- a/tests/functional/openlp_core_lib/test_screen.py +++ b/tests/functional/openlp_core_lib/test_screen.py @@ -84,4 +84,4 @@ class TestScreenList(TestCase): new_screen_count = len(self.screens.screen_list) self.assertEqual(old_screen_count + 1, new_screen_count, 'The new_screens list should be bigger') self.assertEqual(SCREEN, self.screens.screen_list.pop(), - 'The 2nd screen should be identical to the first screen') + 'The 2nd screen should be identical to the first screen') diff --git a/tests/functional/openlp_core_lib/test_serviceitem.py b/tests/functional/openlp_core_lib/test_serviceitem.py index 3c53c8179..15da3b738 100644 --- a/tests/functional/openlp_core_lib/test_serviceitem.py +++ b/tests/functional/openlp_core_lib/test_serviceitem.py @@ -99,9 +99,9 @@ class TestServiceItem(TestCase): # THEN: The frames should also be valid self.assertEqual('Test Custom', service_item.get_display_title(), 'The title should be "Test Custom"') self.assertEqual(VERSE[:-1], service_item.get_frames()[0]['text'], - 'The returned text matches the input, except the last line feed') + 'The returned text matches the input, except the last line feed') self.assertEqual(VERSE.split('\n', 1)[0], service_item.get_rendered_frame(1), - 'The first line has been returned') + 'The first line has been returned') self.assertEqual('Slide 1', service_item.get_frame_title(0), '"Slide 1" has been returned as the title') self.assertEqual('Slide 2', service_item.get_frame_title(1), '"Slide 2" has been returned as the title') self.assertEqual('', service_item.get_frame_title(2), 'Blank has been returned as the title of slide 3') @@ -127,24 +127,24 @@ class TestServiceItem(TestCase): # THEN: We should get back a valid service item self.assertTrue(service_item.is_valid, 'The new service item should be valid') self.assertEqual(test_file, service_item.get_rendered_frame(0), - 'The first frame should match the path to the image') + 'The first frame should match the path to the image') self.assertEqual(frame_array, service_item.get_frames()[0], - 'The return should match frame array1') + 'The return should match frame array1') self.assertEqual(test_file, service_item.get_frame_path(0), - 'The frame path should match the full path to the image') + 'The frame path should match the full path to the image') self.assertEqual(image_name, service_item.get_frame_title(0), - 'The frame title should match the image name') + 'The frame title should match the image name') self.assertEqual(image_name, service_item.get_display_title(), - 'The display title should match the first image name') + 'The display title should match the first image name') self.assertTrue(service_item.is_image(), 'This service item should be of an "image" type') self.assertTrue(service_item.is_capable(ItemCapabilities.CanMaintain), - 'This service item should be able to be Maintained') + 'This service item should be able to be Maintained') self.assertTrue(service_item.is_capable(ItemCapabilities.CanPreview), - 'This service item should be able to be be Previewed') + 'This service item should be able to be be Previewed') self.assertTrue(service_item.is_capable(ItemCapabilities.CanLoop), - 'This service item should be able to be run in a can be made to Loop') + 'This service item should be able to be run in a can be made to Loop') self.assertTrue(service_item.is_capable(ItemCapabilities.CanAppend), - 'This service item should be able to have new items added to it') + 'This service item should be able to have new items added to it') def service_item_load_image_from_local_service_test(self): """ @@ -180,27 +180,27 @@ class TestServiceItem(TestCase): self.assertTrue(service_item.is_valid, 'The first service item should be valid') self.assertTrue(service_item2.is_valid, 'The second service item should be valid') self.assertEqual(test_file1, service_item.get_rendered_frame(0), - 'The first frame should match the path to the image') + 'The first frame should match the path to the image') self.assertEqual(test_file2, service_item2.get_rendered_frame(0), - 'The Second frame should match the path to the image') + 'The Second frame should match the path to the image') self.assertEqual(frame_array1, service_item.get_frames()[0], 'The return should match the frame array1') self.assertEqual(frame_array2, service_item2.get_frames()[0], 'The return should match the frame array2') self.assertEqual(test_file1, service_item.get_frame_path(0), - 'The frame path should match the full path to the image') + 'The frame path should match the full path to the image') self.assertEqual(test_file2, service_item2.get_frame_path(0), - 'The frame path should match the full path to the image') + 'The frame path should match the full path to the image') self.assertEqual(image_name1, service_item.get_frame_title(0), - 'The 1st frame title should match the image name') + 'The 1st frame title should match the image name') self.assertEqual(image_name2, service_item2.get_frame_title(0), - 'The 2nd frame title should match the image name') + 'The 2nd frame title should match the image name') self.assertEqual(service_item.name, service_item.title.lower(), - 'The plugin name should match the display title, as there are > 1 Images') + 'The plugin name should match the display title, as there are > 1 Images') self.assertTrue(service_item.is_image(), 'This service item should be of an "image" type') self.assertTrue(service_item.is_capable(ItemCapabilities.CanMaintain), - 'This service item should be able to be Maintained') + 'This service item should be able to be Maintained') self.assertTrue(service_item.is_capable(ItemCapabilities.CanPreview), - 'This service item should be able to be be Previewed') + 'This service item should be able to be be Previewed') self.assertTrue(service_item.is_capable(ItemCapabilities.CanLoop), - 'This service item should be able to be run in a can be made to Loop') + 'This service item should be able to be run in a can be made to Loop') self.assertTrue(service_item.is_capable(ItemCapabilities.CanAppend), - 'This service item should be able to have new items added to it') + 'This service item should be able to have new items added to it') diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index 8cde77dcd..c42d41dfe 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -4,7 +4,7 @@ from unittest import TestCase -from PyQt4 import QtGui +from PyQt4 import QtGui, QtTest, QtCore from openlp.core.common import Registry from openlp.core.lib import ScreenList, ServiceItem, ItemCapabilities @@ -25,6 +25,7 @@ class TestServiceManager(TestCase): with patch('openlp.core.lib.PluginManager'): self.main_window = MainWindow() self.service_manager = Registry().get('service_manager') + self.event_was_called = False def tearDown(self): """ @@ -35,7 +36,7 @@ class TestServiceManager(TestCase): def basic_service_manager_test(self): """ - Test the Service Manager display functionality + Test the Service Manager UI Functionality """ # GIVEN: A New Service Manager instance @@ -87,7 +88,6 @@ class TestServiceManager(TestCase): self.service_manager.auto_start_action.setVisible.assert_called_once_with(False), \ 'The action should be set invisible.' - def edit_context_menu_test(self): """ Test the context_menu() method with a edit service item @@ -306,3 +306,33 @@ class TestServiceManager(TestCase): self.service_manager.auto_start_action.setVisible.assert_called_with(True), \ 'The action should be set visible.' + def click_on_new_service_test1(self): + """ + Test the on_new_service event handler + """ + # GIVEN: An initial form + self.service_manager.setup_ui(self.service_manager) + + # WHEN displaying the UI and pressing cancel + new_service = self.service_manager.toolbar.actions['newService'] + self.service_manager.on_new_service_clicked = self.dummy_event() + new_service.trigger() + assert self.event_was_called is True, 'The on_new_service_clicked method should have been called' + + def click_on_new_service_test2(self): + """ + Test the on_new_service event handler + """ + # GIVEN: An initial form + self.service_manager.setup_ui(self.service_manager) + + # WHEN displaying the UI and pressing cancel + new_service = self.service_manager.toolbar.actions['newService'] + mocked_event = MagicMock() + self.service_manager.on_new_service_clicked = mocked_event + new_service.trigger() + print(mocked_event.call_count) + assert self.event_was_called == 1, 'The on_new_service_clicked method should have been called' + + def dummy_event(self): + self.event_was_called = True \ No newline at end of file