def test_that_sets_table_when_update_called(self):
        # Arrange
        parent_presenter = create_run_tab_presenter_mock(use_fake_state=False)
        view = create_mock_masking_table()
        presenter = MaskingTablePresenter(parent_presenter)
        presenter._work_handler = mock.Mock()

        presenter.set_view(view)

        self.assertEqual(1, view.set_table.call_count)
        presenter.on_display()

        self.assertEqual(2, view.set_table.call_count)
        first_call = mock.call([])
        second_call = mock.call([
            masking_information(first='Beam stop',
                                second='',
                                third='infinite-cylinder, r = 10.0'),
            masking_information(first='Corners',
                                second='',
                                third='infinite-cylinder, r = 20.0'),
            masking_information(first='Phi',
                                second='',
                                third='L/PHI -90.0 90.0')
        ])  # noqa
        view.set_table.assert_has_calls([first_call, second_call])
Beispiel #2
0
    def test_that_checks_display_mask_is_reenabled_after_error(self):
        # Arrange
        parent_presenter = create_run_tab_presenter_mock(use_fake_state=False)
        presenter = MaskingTablePresenter(parent_presenter)

        presenter.on_processing_error_masking_display = mock.MagicMock()
        presenter._view = mock.MagicMock()
        presenter._view.set_display_mask_button_to_processing = mock.MagicMock()
        presenter._view.get_current_row.side_effect = RuntimeError("Mock get_current_row failure")

        try:
            presenter.on_display()
        except Exception as e:
            self.assertEqual(str(e), "Mock get_current_row failure")
        else:
            self.assertFalse(True)  # As we expect an error to be raised

        # Confirm that on_processing_error_masking_display was called
        self.assertEqual(
            presenter.on_processing_error_masking_display.call_count, 1,
            "Expected on_processing_error_masking_display to have been called. Called {} times.".format(
                presenter.on_processing_error_masking_display.call_count))