Exemple #1
0
    def __init__(self, facility, view=None):
        super(RunTabPresenter, self).__init__()
        self._facility = facility
        # Logger
        self.sans_logger = Logger("SANS")
        # Name of grpah to output to
        self.output_graph = 'SANS-Latest'
        self.progress = 0

        # Models that are being used by the presenter
        self._state_model = None
        self._table_model = TableModel()

        # Presenter needs to have a handle on the view since it delegates it
        self._view = None
        self.set_view(view)
        self._processing = False
        self.work_handler = WorkHandler()
        self.batch_process_runner = BatchProcessRunner(self.notify_progress, self.on_processing_finished, self.on_processing_error)

        # File information for the first input
        self._file_information = None
        self._clipboard = []

        # Settings diagnostic tab presenter
        self._settings_diagnostic_tab_presenter = SettingsDiagnosticPresenter(self)

        # Masking table presenter
        self._masking_table_presenter = MaskingTablePresenter(self)

        # Beam centre presenter
        self._beam_centre_presenter = BeamCentrePresenter(self, WorkHandler, BeamCentreModel, SANSCentreFinder)

        # Workspace Diagnostic page presenter
        self._workspace_diagnostic_presenter = DiagnosticsPagePresenter(self, WorkHandler, run_integral, create_state, self._facility)
    def __init__(self, facility, view=None):
        super(RunTabPresenter, self).__init__()
        self._facility = facility

        # Logger
        self.sans_logger = Logger("SANS")

        # Presenter needs to have a handle on the view since it delegates it
        self._view = None
        self.set_view(view)

        # Models that are being used by the presenter
        self._state_model = None
        self._table_model = None

        # Due to the nature of the DataProcessorWidget we need to provide an algorithm with at least one input
        # workspace and at least one output workspace. Our SANS state approach is not compatible with this. Hence
        # we provide a dummy workspace which is not used. We keep it invisible on the ADS and delete it when the
        # main_presenter is deleted.
        # This is not a nice solution but in line with the SANS dummy algorithm approach that we have provided
        # for the
        self._create_dummy_input_workspace()

        # File information for the first input
        self._file_information = None

        # Settings diagnostic tab presenter
        self._settings_diagnostic_tab_presenter = SettingsDiagnosticPresenter(
            self)

        # Masking table presenter
        self._masking_table_presenter = MaskingTablePresenter(self)

        # Beam centre presenter
        self._beam_centre_presenter = BeamCentrePresenter(self)
Exemple #3
0
    def test_that_set_scaling_is_not_called_when_file_information_does_not_exist(self):
        self.parent_presenter._file_information = None
        self.presenter = BeamCentrePresenter(self.parent_presenter, self.WorkHandler, self.BeamCentreModel,
                                             self.SANSCentreFinder)
        self.presenter.set_view(self.view)

        self.presenter.on_update_rows()
        self.presenter._beam_centre_model.set_scaling.assert_not_called()
    def test_that_set_scaling_is_not_called_when_file_information_does_not_exist(
            self, beam_centre_model_mock):
        self.parent_presenter._file_information = None  #mock.MagicMock(return_value = None)
        self.presenter = BeamCentrePresenter(self.parent_presenter)
        self.presenter.set_view(self.view)

        self.presenter.on_update_rows()
        self.presenter._beam_centre_model.set_scaling.assert_not_called()
    def test_that_set_scaling_is_called_on_update_rows_when_file_information_exists(
            self, beam_centre_model_mock):
        self.presenter = BeamCentrePresenter(self.parent_presenter)
        self.presenter.set_view(self.view)

        self.presenter.on_update_rows()
        self.presenter._beam_centre_model.set_scaling.assert_called_once_with(
            SANSInstrument.LARMOR)
 def setUp(self):
     self.parent_presenter = create_run_tab_presenter_mock(
         use_fake_state=False)
     self.parent_presenter._file_information = mock.MagicMock()
     self.parent_presenter._file_information.get_instrument = mock.MagicMock(
         return_value=SANSInstrument.LARMOR)
     self.presenter = BeamCentrePresenter(self.parent_presenter)
     self.view = create_mock_beam_centre_tab()
Exemple #7
0
 def setUp(self):
     self.parent_presenter = create_run_tab_presenter_mock(use_fake_state = False)
     self.view = create_mock_beam_centre_tab()
     self.WorkHandler = mock.MagicMock()
     self.BeamCentreModel = mock.MagicMock()
     self.SANSCentreFinder = mock.MagicMock()
     self.presenter = BeamCentrePresenter(self.parent_presenter, self.SANSCentreFinder,
                                          work_handler=self.WorkHandler, beam_centre_model=self.BeamCentreModel)
     self.presenter.connect_signals = mock.Mock()
     self.presenter.set_view(self.view)
Exemple #8
0
 def setUp(self):
     self.parent_presenter = create_run_tab_presenter_mock(use_fake_state = False)
     self.parent_presenter._file_information = mock.MagicMock()
     self.parent_presenter._file_information.get_instrument = mock.MagicMock(return_value = SANSInstrument.LARMOR)
     self.view = create_mock_beam_centre_tab()
     self.WorkHandler = mock.MagicMock()
     self.BeamCentreModel = mock.MagicMock()
     self.SANSCentreFinder = mock.MagicMock()
     self.presenter = BeamCentrePresenter(self.parent_presenter, self.WorkHandler, self.BeamCentreModel,
                                          self.SANSCentreFinder)
     self.presenter.connect_signals = mock.Mock()
    def test_that_on_run_clicked_calls_find_beam_centre(
            self, work_handler_mock):
        self.presenter = BeamCentrePresenter(self.parent_presenter)
        self.presenter.set_view(self.view)
        self.presenter.on_run_clicked()

        self.assertTrue(work_handler_mock.return_value.process.call_count == 1)
        self.assertTrue(work_handler_mock.return_value.process.call_args[0][1]
                        == find_beam_centre)
        self.assertTrue(work_handler_mock.return_value.process.call_args[0][3]
                        == self.presenter._beam_centre_model)