forked from openlp/openlp
Patch Registry.execute so that it is undoen at end of test
This commit is contained in:
parent
2555bc50d4
commit
9a1ce000b7
@ -508,18 +508,18 @@ class TestSlideController(TestCase):
|
|||||||
mocked_update_preview = MagicMock()
|
mocked_update_preview = MagicMock()
|
||||||
mocked_preview_widget = MagicMock()
|
mocked_preview_widget = MagicMock()
|
||||||
mocked_slide_selected = MagicMock()
|
mocked_slide_selected = MagicMock()
|
||||||
Registry.execute = mocked_execute
|
with patch.object(Registry, 'execute') as mocked_execute:
|
||||||
Registry.create()
|
Registry.create()
|
||||||
slide_controller = SlideController(None)
|
slide_controller = SlideController(None)
|
||||||
slide_controller.service_item = mocked_item
|
slide_controller.service_item = mocked_item
|
||||||
slide_controller.update_preview = mocked_update_preview
|
slide_controller.update_preview = mocked_update_preview
|
||||||
slide_controller.preview_widget = mocked_preview_widget
|
slide_controller.preview_widget = mocked_preview_widget
|
||||||
slide_controller.slide_selected = mocked_slide_selected
|
slide_controller.slide_selected = mocked_slide_selected
|
||||||
slide_controller.is_live = True
|
slide_controller.is_live = True
|
||||||
|
|
||||||
# WHEN: The method is called
|
# WHEN: The method is called
|
||||||
slide_controller.on_slide_selected_index([9])
|
slide_controller.on_slide_selected_index([9])
|
||||||
|
|
||||||
# THEN: It should have sent a notification
|
# THEN: It should have sent a notification
|
||||||
mocked_item.is_command.assert_called_once_with()
|
mocked_item.is_command.assert_called_once_with()
|
||||||
mocked_execute.assert_called_once_with('mocked item_slide', [mocked_item, True, 9])
|
mocked_execute.assert_called_once_with('mocked item_slide', [mocked_item, True, 9])
|
||||||
@ -539,16 +539,16 @@ class TestSlideController(TestCase):
|
|||||||
mocked_update_preview = MagicMock()
|
mocked_update_preview = MagicMock()
|
||||||
mocked_preview_widget = MagicMock()
|
mocked_preview_widget = MagicMock()
|
||||||
mocked_slide_selected = MagicMock()
|
mocked_slide_selected = MagicMock()
|
||||||
Registry.execute = mocked_execute
|
with patch.object(Registry, 'execute') as mocked_execute:
|
||||||
Registry.create()
|
Registry.create()
|
||||||
slide_controller = SlideController(None)
|
slide_controller = SlideController(None)
|
||||||
slide_controller.service_item = mocked_item
|
slide_controller.service_item = mocked_item
|
||||||
slide_controller.update_preview = mocked_update_preview
|
slide_controller.update_preview = mocked_update_preview
|
||||||
slide_controller.preview_widget = mocked_preview_widget
|
slide_controller.preview_widget = mocked_preview_widget
|
||||||
slide_controller.slide_selected = mocked_slide_selected
|
slide_controller.slide_selected = mocked_slide_selected
|
||||||
|
|
||||||
# WHEN: The method is called
|
# WHEN: The method is called
|
||||||
slide_controller.on_slide_selected_index([7])
|
slide_controller.on_slide_selected_index([7])
|
||||||
|
|
||||||
# THEN: It should have sent a notification
|
# THEN: It should have sent a notification
|
||||||
mocked_item.is_command.assert_called_once_with()
|
mocked_item.is_command.assert_called_once_with()
|
||||||
@ -556,3 +556,5 @@ class TestSlideController(TestCase):
|
|||||||
self.assertEqual(0, mocked_update_preview.call_count, 'Update preview should not have been called')
|
self.assertEqual(0, mocked_update_preview.call_count, 'Update preview should not have been called')
|
||||||
mocked_preview_widget.change_slide.assert_called_once_with(7)
|
mocked_preview_widget.change_slide.assert_called_once_with(7)
|
||||||
mocked_slide_selected.assert_called_once_with()
|
mocked_slide_selected.assert_called_once_with()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user