def test_replace_service_manager_item_same_item(self): """ Test that when the service item is the same, the service item is reprocessed """ # GIVEN: A slide controller and a new item to add mocked_item = MagicMock() mocked_preview_widget = MagicMock() mocked_preview_widget.current_slide_number.return_value = 7 mocked_process_item = MagicMock() slide_controller = SlideController(None) slide_controller.preview_widget = mocked_preview_widget slide_controller._process_item = mocked_process_item slide_controller.service_item = mocked_item # WHEN: The service item is replaced slide_controller.replace_service_manager_item(mocked_item) # THEN: The service item should not be processed mocked_preview_widget.current_slide_number.assert_called_with() mocked_process_item.assert_called_once_with(mocked_item, 7)
def test_replace_service_manager_item_different_items(self): """ Test that when the service items are not the same, nothing happens """ # GIVEN: A slide controller and a new item to add mocked_item = MagicMock() mocked_preview_widget = MagicMock() mocked_process_item = MagicMock() slide_controller = SlideController(None) slide_controller.preview_widget = mocked_preview_widget slide_controller._process_item = mocked_process_item slide_controller.service_item = None # WHEN: The service item is replaced slide_controller.replace_service_manager_item(mocked_item) # THEN: The service item should not be processed assert 0 == mocked_process_item.call_count, 'The _process_item() method should not have been called' assert 0 == mocked_preview_widget.current_slide_number.call_count, \ 'The preview_widget current_slide_number.() method should not have been called'