forked from openlp/openlp
More tests
This commit is contained in:
parent
c8a3b33044
commit
e49beeb2c4
@ -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.
|
||||
"""
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user