def setUp(self):
        self.load=mock.create_autospec(load_utils.LoadUtils,spec_set=True)
        self.load.getCurrentWS=mock.Mock(return_value=["TEST00000001",["fwd","bkwd"]])
        self.load.hasDataChanged = mock.MagicMock(return_value=False)

        self.model=mock.create_autospec(maxent_model.MaxEntModel,spec_set=True)

        self.view=mock.create_autospec(maxent_view.MaxEntView,spec_set=True)
        #signals
        #needed for connect in presenter
        self.view.maxEntButtonSignal=mock.Mock()
        self.view.cancelSignal=mock.Mock()
        self.view.phaseSignal=mock.Mock()
        # functions
        self.view.addItems=mock.MagicMock()
        self.view.initMaxEntInput=mock.Mock(return_value={"InputWorkspace":"testWS","EvolChi":"out",
                                            "ReconstructedData":"out2","ReconstructedImage":"out3","EvolAngle":"out4"})
        self.view.deactivateCalculateButton=mock.Mock()
        self.view.activateCalculateButton=mock.Mock()
        self.view.usePhases = mock.Mock(return_value=False)
         #set presenter
        self.presenter=maxent_presenter.MaxEntPresenter(self.view,self.model,self.load)

        # make thread
        self.thread=mock.create_autospec(thread_model.ThreadModel)
        self.thread.start=mock.Mock()
        self.thread.started=mock.Mock()
        self.thread.finished=mock.Mock()
        self.thread.setInputs=mock.Mock()
        self.thread.loadData=mock.Mock()
        self.thread.threadWrapperSetup = mock.Mock()
        self.thread.threadWrapperTearDown = mock.Mock()
Esempio n. 2
0
 def setUp(self):
     self._view = mock.create_autospec(LoadView)
     self._load_model = mock.create_autospec(LoadModel)
     self._co_model = mock.create_autospec(CoLoadModel)
     self.presenter = LoadPresenter(self._view, self._load_model,
                                    self._co_model)
     self.view = self.presenter.view
    def setUp(self):
        self._qapp = mock_widget.mockQapp()

        self._view = mock.create_autospec(LoadView)
        self._load_model = mock.create_autospec(LoadModel)
        self._co_model = mock.create_autospec(CoLoadModel)
        self.presenter = LoadPresenter(
            self._view, self._load_model, self._co_model)
        self.view = self.presenter.view
Esempio n. 4
0
    def setUp(self):
        self.load = mock.create_autospec(load_utils.LoadUtils, spec_set=True)
        self.load.getCurrentWS = mock.Mock(
            return_value=["TEST00000001", ["fwd", "bkwd"]])
        self.load.getRunName = mock.MagicMock(return_value="MUSR00023456")
        self.load.version = 1
        self.load.hasDataChanged = mock.MagicMock(return_value=False)
        self.view = mock.create_autospec(fft_view.FFTView, spec_set=True)
        # signals
        self.view.tableClickSignal = mock.Mock(return_value=[3, 1])
        self.view.phaseCheckSignal = mock.Mock(return_value=True)
        # needed for connect in presenter
        self.view.buttonSignal = mock.Mock()
        self.view.tableClickSignal = mock.Mock()
        self.view.phaseCheckSignal = mock.Mock()
        self.view.changed = mock.MagicMock()
        self.view.changedHideUnTick = mock.MagicMock()
        self.view.initFFTInput = mock.Mock(
            return_value={
                "InputWorkspace": "testWS",
                "OutputWorkspace": "muon"})
        self.view.addFFTComplex = mock.Mock(
            return_value={"InputImWorkspace": "MuonFFT"})
        self.view.addFFTShift = mock.Mock()
        self.view.addRaw = mock.Mock()
        self.view.RePhaseAdvanced = mock.Mock()
        self.view.getFFTRePhase = mock.Mock()
        self.view.getFFTImPhase = mock.Mock()
        self.view.getWS = mock.Mock(return_value="MUSR00023456")
        self.view.getFirstGoodData = mock.Mock(return_value=0.1)
        self.view.getLastGoodData = mock.Mock(return_value=15.)
        self.view.getImBoxRow = mock.Mock(return_value=3)
        self.view.getShiftBoxRow = mock.Mock(return_value=5)
        self.view.isRaw = mock.Mock(return_value=True)
        self.view.isComplex = mock.Mock(return_value=True)
        self.view.isAutoShift = mock.Mock(return_value=True)
        self.view.setPhaseBox = mock.Mock()
        self.view.isNewPhaseTable = mock.Mock(return_value=True)
        self.view.activateButton = mock.Mock()
        self.view.deactivateButton = mock.Mock()
        # setup model
        self.model1 = mock.create_autospec(fft_model.FFTModel, spec_set=False)
        self.model = mock.create_autospec(fft_model.FFTWrapper, spec_set=False)

        # set presenter
        self.presenter = fft_presenter.FFTPresenter(
            self.view, self.model, self.load)

        # mock thread
        self.thread = mock.create_autospec(thread_model.ThreadModel)
        self.thread.start = mock.Mock()
        self.thread.started = mock.Mock()
        self.thread.finished = mock.Mock()
        self.thread.setInputs = mock.Mock()
        self.thread.loadData = mock.Mock()
        self.presenter.createThread = mock.Mock(return_value=self.thread)
Esempio n. 5
0
    def setUp(self):
        self.load = mock.create_autospec(load_utils.LoadUtils, spec_set=True)
        self.load.getCurrentWS = mock.Mock(
            return_value=["TEST00000001", ["fwd", "bkwd"]])
        self.load.getRunName = mock.MagicMock(return_value="MUSR00023456")
        self.load.version = 1
        self.load.hasDataChanged = mock.MagicMock(return_value=False)
        self.view = mock.create_autospec(fft_view.FFTView, spec_set=True)
        # signals
        self.view.tableClickSignal = mock.Mock(return_value=[3, 1])
        self.view.phaseCheckSignal = mock.Mock(return_value=True)
        # needed for connect in presenter
        self.view.buttonSignal = mock.Mock()
        self.view.tableClickSignal = mock.Mock()
        self.view.phaseCheckSignal = mock.Mock()
        self.view.changed = mock.MagicMock()
        self.view.changedHideUnTick = mock.MagicMock()
        self.view.initFFTInput = mock.Mock(return_value={
            "InputWorkspace": "testWS",
            "OutputWorkspace": "muon"
        })
        self.view.addFFTComplex = mock.Mock(
            return_value={"InputImWorkspace": "MuonFFT"})
        self.view.addFFTShift = mock.Mock()
        self.view.addRaw = mock.Mock()
        self.view.RePhaseAdvanced = mock.Mock()
        self.view.getFFTRePhase = mock.Mock()
        self.view.getFFTImPhase = mock.Mock()
        self.view.getWS = mock.Mock(return_value="MUSR00023456")
        self.view.getFirstGoodData = mock.Mock(return_value=0.1)
        self.view.getLastGoodData = mock.Mock(return_value=15.)
        self.view.getImBoxRow = mock.Mock(return_value=3)
        self.view.getShiftBoxRow = mock.Mock(return_value=5)
        self.view.isRaw = mock.Mock(return_value=True)
        self.view.isComplex = mock.Mock(return_value=True)
        self.view.isAutoShift = mock.Mock(return_value=True)
        self.view.setPhaseBox = mock.Mock()
        self.view.isNewPhaseTable = mock.Mock(return_value=True)
        self.view.activateButton = mock.Mock()
        self.view.deactivateButton = mock.Mock()
        # setup model
        self.model1 = mock.create_autospec(fft_model.FFTModel, spec_set=False)
        self.model = mock.create_autospec(fft_model.FFTWrapper, spec_set=False)

        # set presenter
        self.presenter = fft_presenter.FFTPresenter(self.view, self.model,
                                                    self.load)

        # mock thread
        self.thread = mock.create_autospec(thread_model.ThreadModel)
        self.thread.start = mock.Mock()
        self.thread.started = mock.Mock()
        self.thread.finished = mock.Mock()
        self.thread.setInputs = mock.Mock()
        self.thread.loadData = mock.Mock()
        self.presenter.createThread = mock.Mock(return_value=self.thread)
Esempio n. 6
0
    def setUp(self):
        self._qapp = mock_widget.mockQapp()

        self.view = PlotView()

        self.mock_func = mock.Mock(return_value=True)
        self.mock_args = [mock.Mock() for i in range(3)]
        self.mock_kwargs = {}
        self.mock_name = mock.Mock()

        self.plot_name = "test plot"
        self.plots_return_value = mock.Mock()
        self.plots_return_value.set_position = mock.Mock()
        self.plots_return_value.set_subplotspec = mock.Mock()
        self.plots_return_value.remove = mock.Mock()

        self.view.figure = mock.Mock()
        self.view.figure.tight_layout = mock.Mock()
        self.view.figure.add_subplot = mock.Mock(
            return_value=self.plots_return_value)
        self.view.canvas = mock.Mock()
        self.view.canvas.draw = mock.Mock()

        self.view.plots = {self.plot_name: self.plots_return_value}
        self.mock_plot = mock.Mock()
        self.mock_plot.get_xlim = mock.Mock()
        self.mock_plot.get_ylim = mock.Mock()
        self.mock_workspace = mock.Mock()

        self.mock_bounds = mock.Mock()

        self.mock_grid_pos = mock.Mock()
        self.view.current_grid = mock.Mock()
        self.view.current_grid.__getitem__ = mock.Mock(
            return_value=self.mock_grid_pos)
        self.mock_grid_pos.get_position = mock.Mock(return_value=True)

        self.view.gridspecs = mock.Mock()
        self.view.gridspecs.__getitem__ = mock.Mock(
            return_value=self.view.current_grid)

        self.view.plot_selector = mock.Mock()
        self.view.plot_selector.currentText = mock.Mock(
            return_value=self.plot_name)
        self.view.plot_selector.clear = mock.Mock()
        self.view.plot_selector.addItems = mock.Mock()

        self.view.x_axis_changer = mock.create_autospec(AxisChangerPresenter)
        self.view.y_axis_changer = mock.create_autospec(AxisChangerPresenter)

        self.view.errors = mock.Mock()
        self.view.errors.blockSignals = mock.Mock()
        self.view.errors.setChecked = mock.Mock()
 def _make_mock_view(self):
     mock_view = mock.create_autospec(SummationSettingsWidget, spec_set=True)
     mock_view.binningTypeChanged = FakeSignal()
     mock_view.preserveEventsChanged = FakeSignal()
     mock_view.additionalTimeShiftsChanged = FakeSignal()
     mock_view.binSettingsChanged = FakeSignal()
     return mock_view
Esempio n. 8
0
 def _make_mock_view(self):
     mock_view = mock.create_autospec(RunSelectorWidget, spec_set=True)
     mock_view.addRuns = FakeSignal()
     mock_view.removeRuns = FakeSignal()
     mock_view.manageDirectories = FakeSignal()
     mock_view.browse = FakeSignal()
     mock_view.removeAllRuns = FakeSignal()
     return mock_view
 def _make_mock_view(self):
     mock_view = mock.create_autospec(RunSelectorWidget, spec_set=True)
     mock_view.addRuns = FakeSignal()
     mock_view.removeRuns = FakeSignal()
     mock_view.manageDirectories = FakeSignal()
     mock_view.browse = FakeSignal()
     mock_view.removeAllRuns = FakeSignal()
     return mock_view
Esempio n. 10
0
    def setUp(self):
        self.load = mock.MagicMock()
        self.fft = mock.create_autospec(fft_presenter.FFTPresenter, spec_Set=True)
        self.maxent = mock.create_autospec(maxent_presenter.MaxEntPresenter, spec_set=True)

        # create widget
        self.widget = transform_widget.TransformWidget(self.load, FFTWidget, MaxEntWidget)
        # create the view
        self.view = mock.create_autospec(transform_view.TransformView, spec_set=False)
        self.view.getView = mock.Mock()
        self.view.getMethods = mock.Mock(return_value=["FFT", "MaxEnt"])
        self.view.hideAll = mock.Mock()
        self.view.showMethod = mock.Mock()
        self.view.selection = mock.create_autospec(transform_selection_view.TransformSelectionView, spec_set=True)
        self.view.selection.changeMethodSignal = mock.Mock()
        # set the mocked view to the widget
        self.widget.mockWidget(self.view)
Esempio n. 11
0
    def setUp(self):
        self.view = mock.create_autospec(view.View)

        # mock view
        self.view.doSomethingSignal = mock.Mock()
        self.view.btn_click = mock.Mock()
        self.view.getValue = mock.Mock(return_value=3.14)

        self.presenter = presenter.Presenter(self.view)
Esempio n. 12
0
    def setUp(self):
        self.model = mock.create_autospec(maxent_model.MaxEntModel,
                                          spec_set=True)
        self.model.setRun = mock.Mock()
        self.model.MaxEntAlg = mock.Mock()
        self.model.makePhaseTable = mock.Mock()

        # set presenter
        self.wrapper = maxent_model.MaxEntWrapper(self.model)
Esempio n. 13
0
    def test_legend_set_draggable(self):
        legend = create_autospec(Legend)
        args = (None, False, 'loc')
        legend_set_draggable(legend, *args)

        if hasattr(Legend, 'set_draggable'):
            legend.set_draggable.assert_called_with(*args)
        else:
            legend.draggable.assert_called_with(*args)
Esempio n. 14
0
    def setUp(self):
        self._qapp = mock_widget.mockQapp()
        self.load=  mock.create_autospec( load_utils.LoadUtils,spec_set=True)
        self.fft=   mock.create_autospec( fft_presenter.FFTPresenter,spec_Set=True)
        self.maxent=mock.create_autospec( maxent_presenter.MaxEntPresenter,spec_set=True)

        # create widget
        self.widget=transform_widget.TransformWidget(self.load, FFTWidget, MaxEntWidget)
        # create the view
        self.view=mock.create_autospec(transform_view.TransformView,spec_set=False)
        self.view.getView=mock.Mock()
        self.view.getMethods=mock.Mock(return_value=["FFT","MaxEnt"])
        self.view.hideAll=mock.Mock()
        self.view.showMethod=mock.Mock()
        self.view.selection=mock.create_autospec(transform_selection_view.TransformSelectionView,spec_set=True)
        self.view.selection.changeMethodSignal=mock.Mock()
        # set the mocked view to the widget
        self.widget.mockWidget(self.view)  
Esempio n. 15
0
    def setUp(self):
        self.model=mock.create_autospec(fft_model.FFTModel,spec_set=True)
        self.model.setRun=mock.Mock()
        self.model.preAlg=mock.Mock()
        self.model.FFTAlg=mock.Mock()
        self.model.makePhaseQuadTable=mock.Mock()
        self.model.PhaseQuad=mock.Mock()

        #set presenter
        self.wrapper=fft_model.FFTWrapper(self.model)
Esempio n. 16
0
    def setUp(self):
        self.model = mock.create_autospec(fft_model.FFTModel, spec_set=True)
        self.model.setRun = mock.Mock()
        self.model.preAlg = mock.Mock()
        self.model.FFTAlg = mock.Mock()
        self.model.makePhaseQuadTable = mock.Mock()
        self.model.PhaseQuad = mock.Mock()

        #set presenter
        self.wrapper = fft_model.FFTWrapper(self.model)
Esempio n. 17
0
    def test_that_rm_line_calls_correct_function_if_window_not_none(self):
        self.gui.plotting = MultiPlotWidget(mock.Mock())
        self.gui.plotting.get_subplots = mock.Mock(return_value=['plot1', 'plot2', 'plot3'])
        self.gui.plotting.rm_vline_and_annotate = mock.Mock()
        self.gui.plot_window = mock.create_autospec(MultiPlotWindow)
        self.gui._rm_line('line')

        self.assertEqual(self.gui.plotting.get_subplots.call_count, 1)
        self.assertEqual(self.gui.plotting.rm_vline_and_annotate.call_count, 3)
        self.gui.plotting.rm_vline_and_annotate.assert_called_with('plot3', 'line')
Esempio n. 18
0
    def setUp(self):
        self.model = mock.create_autospec(
            maxent_model.MaxEntModel,
            spec_set=True)
        self.model.setRun = mock.Mock()
        self.model.MaxEntAlg = mock.Mock()
        self.model.makePhaseTable = mock.Mock()

        # set presenter
        self.wrapper = maxent_model.MaxEntWrapper(self.model)
Esempio n. 19
0
    def test_that_plot_line_calls_plot_line_once_if_window_not_none(self, mock_plot_line_once,
                                                                    mock_gen_label):
        self.gui.plot_window = mock.create_autospec(MultiPlotWindow)
        self.gui.plotting = MultiPlotWidget(mock.Mock())
        self.gui.plotting.get_subplots = mock.Mock(return_value=['plot1'])
        mock_gen_label.return_value = 'name of the label'
        self.gui._plot_line('name', 1.0, 'C0', None)

        self.assertEqual(mock_plot_line_once.call_count, 1)
        mock_plot_line_once.assert_called_with('plot1', 1.0, 'name of the label', 'C0')
Esempio n. 20
0
def create_run_tab_presenter_mock(use_fake_state=True):
    presenter = mock.create_autospec(RunTabPresenter, spec_set=False)
    presenter.get_row_indices = mock.MagicMock(return_value=[0, 1, 3])
    presenter._table_model = mock.MagicMock()
    presenter._facility = SANSFacility.ISIS
    if use_fake_state:
        presenter.get_state_for_row = mock.MagicMock(side_effect=get_state_for_row_mock)
    else:
        presenter.get_state_for_row = mock.MagicMock(side_effect=get_state_for_row_mock_with_real_state)
    return presenter
Esempio n. 21
0
def create_run_tab_presenter_mock(use_fake_state=True):
    presenter = mock.create_autospec(RunTabPresenter, spec_set=False)
    presenter.get_row_indices = mock.MagicMock(return_value=[0, 1, 3])
    presenter._table_model = mock.MagicMock()
    presenter._facility = SANSFacility.ISIS
    if use_fake_state:
        presenter.get_state_for_row = mock.MagicMock(side_effect=get_state_for_row_mock)
    else:
        presenter.get_state_for_row = mock.MagicMock(side_effect=get_state_for_row_mock_with_real_state)
    return presenter
 def test_add_line_1(self):
     specNum = 4
     ws = mock.MagicMock()
     # add mock subplot
     subplot = mock.MagicMock()
     self.subplot = mock.create_autospec(subplotContext)
     with mock.patch("MultiPlotting.subplot.subplot_context.subplotContext.addLine") as patch:
         self.context.addSubplot("one",subplot) 
         self.context.addLine("one",ws,specNum)
         self.assertEquals(patch.call_count,1)
         patch.assert_called_with(ws,specNum)
    def setUp(self):
        self._model = mock.create_autospec(PeriodicTableModel)
        self.view = PeriodicTableView()
        self.presenter = PeriodicTablePresenter(self.view, self._model)
        self.presenter.is_selected = mock.Mock()
        self.mock_elem = mock.create_autospec(PeriodicTableItem)
        self.mock_elem.symbol = mock.Mock()

        self.view.ptable = mock.create_autospec(silxPT)
        self.view.ptable.getSelection = mock.Mock(return_value=self.mock_elem)
        self.view.ptable.isElementSelected = mock.Mock(return_value=True)

        self.view.on_table_lclicked = mock.Mock()
        self.view.on_table_rclicked = mock.Mock()
        self.view.on_table_changed = mock.Mock()

        self.view.unreg_on_table_lclicked = mock.Mock()
        self.view.unreg_on_table_rclicked = mock.Mock()
        self.view.unreg_on_table_changed = mock.Mock()

        self.presenter.view = self.view
Esempio n. 24
0
 def test_add_line_1(self):
     spec_num = 4
     ws = mock.MagicMock()
     # add mock subplot
     subplot = mock.MagicMock()
     self.subplot = mock.create_autospec(subplotContext)
     with mock.patch(
             "MultiPlotting.subplot.subplot_context.subplotContext.addLine"
     ) as patch:
         self.context.addSubplot("one", subplot)
         self.context.addLine("one", ws, spec_num, 'C0')
         self.assertEqual(patch.call_count, 1)
         patch.assert_called_with(ws, spec_num, color='C0')
 def test_add_line_2(self):
     specNum = 4
     mockWS = mock.MagicMock()
     ws = gen_ws(mockWS)
     # add mock subplot
     subplot = mock.MagicMock()
     self.subplot = mock.create_autospec(subplotContext)
     with mock.patch(
             "MultiPlotting.subplot.subplot_context.subplotContext.addLine"
     ) as patch:
         self.context.addSubplot("one", subplot)
         self.context.addLine("one", ws, specNum)
         self.assertEqual(patch.call_count, 1)
         patch.assert_called_with(mockWS, specNum)
Esempio n. 26
0
    def setUp(self):
        self.view = mock.create_autospec(view.View)

        # mock view
        self.view.plotSignal = mock.Mock()
        self.view.getColour = mock.Mock(return_value="black")
        self.view.getGridLines = mock.Mock(return_value=True)
        self.view.getFreq = mock.Mock(return_value=3.14)
        self.view.getPhase = mock.Mock(return_value=0.56)
        self.view.buttonPressed = mock.Mock()
        self.view.setTableRow = mock.Mock()
        self.view.addWidgetToTable = mock.Mock()
        self.view.addITemToTable = mock.Mock()

        self.presenter = presenter.Presenter(self.view)
    def test_updateLayout(self):
        # add mocks
        figure = mock.Mock()
        self.subplot = mock.create_autospec(subplotContext)
        names = ["one","two","three"]
        for name in names:
            self.context.addSubplot(name, mock.Mock())

        gridspec = mock.Mock()
        self.context._gridspec = gridspec
        with mock.patch("MultiPlotting.subplot.subplot_context.subplotContext.update_gridspec") as patch:
            self.context.update_layout(figure)
            self.assertEquals(patch.call_count,3)
            # only last iteration survives
            patch.assert_called_with(gridspec,figure,2)
    def setUp(self):
        self._model = mock.create_autospec(PeriodicTableModel)
        self.view = PeriodicTableView()
        self.presenter = PeriodicTablePresenter(
            self.view, self._model)
        self.presenter.is_selected = mock.Mock()
        self.mock_elem = mock.create_autospec(PeriodicTableItem)
        self.mock_elem.symbol = mock.Mock()

        self.view.ptable = mock.create_autospec(silxPT)
        self.view.ptable.getSelection = mock.Mock(
            return_value=self.mock_elem)
        self.view.ptable.isElementSelected = mock.Mock(
            return_value=True)

        self.view.on_table_lclicked = mock.Mock()
        self.view.on_table_rclicked = mock.Mock()
        self.view.on_table_changed = mock.Mock()

        self.view.unreg_on_table_lclicked = mock.Mock()
        self.view.unreg_on_table_rclicked = mock.Mock()
        self.view.unreg_on_table_changed = mock.Mock()

        self.presenter.view = self.view
Esempio n. 29
0
    def test_update_layout(self):
        # add mocks
        figure = mock.Mock()
        self.subplot = mock.create_autospec(subplotContext)
        names = ["one", "two", "three"]
        for name in names:
            self.context.addSubplot(name, mock.Mock())

        gridspec = mock.Mock()
        self.context._gridspec = gridspec
        with mock.patch(
                "MultiPlotting.subplot.subplot_context.subplotContext.update_gridspec"
        ) as patch:
            self.context.update_layout(figure)
            self.assertEqual(patch.call_count, 3)
            # only last iteration survives
            patch.assert_called_with(gridspec, figure, 2)
Esempio n. 30
0
def create_mock_view(user_file_path,
                     batch_file_path=None,
                     row_user_file_path=""):
    get_cell_mock_with_path = partial(get_cell_mock,
                                      user_file_path=row_user_file_path)

    view = mock.create_autospec(SANSDataProcessorGui, spec_set=False)
    view.get_user_file_path = mock.Mock(return_value=user_file_path)
    view.get_cell = mock.MagicMock(side_effect=get_cell_mock_with_path)
    view.get_batch_file_path = mock.MagicMock(return_value=batch_file_path)
    view.get_number_of_rows = mock.MagicMock(return_value=2)

    # Add the settings diagnostic mock
    settings_diagnostic_tab = create_mock_settings_diagnostic_tab()
    view.settings_diagnostic_tab = settings_diagnostic_tab

    # Add the masking table view
    masking_table = create_mock_masking_table()
    view.masking_table = masking_table

    # Add the beam centre view
    beam_centre = create_mock_beam_centre_tab()
    view.beam_centre = beam_centre

    # Add the data diagnostic tab
    diagnostic_page = create_mock_diagnostics_tab()
    view.diagnostic_page = diagnostic_page

    view.halt_process_flag = mock.MagicMock()

    # Mock objects used in the properties handler
    view.user_file_line_edit = mock.Mock()

    # Mock the add runs presenter
    view.add_runs_presenter = mock.Mock()

    # ---------------------
    # Mocking properties
    # ---------------------
    _event_slices = mock.PropertyMock(return_value="")
    type(view).event_slices = _event_slices

    _merge_scale = mock.PropertyMock(return_value=1.)
    type(view).merge_scale = _merge_scale

    _merge_shift = mock.PropertyMock(return_value=0.)
    type(view).merge_shift = _merge_shift

    _merge_q_range_start = mock.PropertyMock(return_value=None)
    type(view).merge_q_range_start = _merge_q_range_start

    _merge_q_range_stop = mock.PropertyMock(return_value=None)
    type(view).merge_q_range_stop = _merge_q_range_stop

    _merge_q_range_stop = mock.PropertyMock(return_value=None)
    type(view).merge_q_range_stop = _merge_q_range_stop

    _merge_min = mock.PropertyMock(return_value=None)
    type(view).merge_min = _merge_min

    _merge_max = mock.PropertyMock(return_value=None)
    type(view).merge_max = _merge_max

    _sample_height = mock.PropertyMock(return_value=None)
    type(view).sample_height = _sample_height

    _sample_width = mock.PropertyMock(return_value=None)
    type(view).sample_width = _sample_width

    _sample_thickness = mock.PropertyMock(return_value=None)
    type(view).sample_thickness = _sample_thickness

    _sample_shape = mock.PropertyMock(return_value=None)
    type(view).sample_shape = _sample_shape

    _pixel_adjustment_det_1 = mock.PropertyMock(return_value="")
    type(view).pixel_adjustment_det_1 = _pixel_adjustment_det_1

    _pixel_adjustment_det_2 = mock.PropertyMock(return_value="")
    type(view).pixel_adjustment_det_2 = _pixel_adjustment_det_2

    _wavelength_adjustment_det_1 = mock.PropertyMock(return_value="")
    type(view).wavelength_adjustment_det_1 = _wavelength_adjustment_det_1

    _wavelength_adjustment_det_2 = mock.PropertyMock(return_value="")
    type(view).wavelength_adjustment_det_2 = _wavelength_adjustment_det_2

    _gravity_extra_length = mock.PropertyMock(return_value=None)
    type(view).gravity_extra_length = _gravity_extra_length

    _q_resolution_source_h = mock.PropertyMock(return_value=None)
    type(view).q_resolution_source_h = _q_resolution_source_h

    _q_resolution_sample_h = mock.PropertyMock(return_value=None)
    type(view).q_resolution_sample_h = _q_resolution_sample_h

    _q_resolution_source_w = mock.PropertyMock(return_value=None)
    type(view).q_resolution_source_w = _q_resolution_source_w

    _q_resolution_sample_w = mock.PropertyMock(return_value=None)
    type(view).q_resolution_sample_w = _q_resolution_sample_w

    _phi_limit_min = mock.PropertyMock(return_value=None)
    type(view).phi_limit_min = _phi_limit_min

    _phi_limit_max = mock.PropertyMock(return_value=None)
    type(view).phi_limit_max = _phi_limit_max

    _phi_limit_max = mock.PropertyMock(return_value=None)
    type(view).phi_limit_max = _phi_limit_max

    _q_1d_step = mock.PropertyMock(return_value=.001)
    type(view).q_1d_step = _q_1d_step

    _q_1d_step_type = mock.PropertyMock(return_value=RangeStepType.Lin)
    type(view)._q_1d_step_type = _q_1d_step_type

    _output_mode = mock.PropertyMock(return_value=OutputMode.PublishToADS)
    type(view).output_mode = _output_mode

    _wavelength_range = mock.PropertyMock(return_value='')
    type(view).wavelength_range = _wavelength_range

    _instrument = mock.PropertyMock(return_value=SANSInstrument.SANS2D)
    type(view).instrument = _instrument

    return view, settings_diagnostic_tab, masking_table
Esempio n. 31
0
def create_mock_diagnostics_tab():
    view = mock.create_autospec(DiagnosticsPage, spec_set=False)
    return view
 def _make_fake_histogram_run(self):
     run = mock.create_autospec(SummableRunFile, spec_set=True)
     run.display_name.return_value = '10'
     run.is_event_data.return_value = False
     return run
Esempio n. 33
0
 def setUp(self):
     self.view = mock.create_autospec(view.CalibrationView)
     self.model = mock.create_autospec(model.CalibrationModel)
     self.presenter = presenter.CalibrationPresenter(self.model, self.view)
 def _make_mock_run_summation(self):
     return mock.create_autospec(RunSummation, spec_set=True)
 def _make_mock_selection(self):
     return mock.create_autospec(RunSelection)
Esempio n. 36
0
 def setUp(self):
     self._qapp = mock_widget.mockQapp()
     self.pres = mock.create_autospec(QuickEditPresenter)
     self.widget = QuickEditWidget()
     self.slot = mock.Mock()
     self.widget.set_mock(self.pres)
 def _make_mock_run_selector_presenter(self):
     return mock.create_autospec(RunSelectorPresenter, spec_set=True)
 def _make_mock_finder(self):
     return mock.create_autospec(SummableRunFinder)
 def _make_mock_summation_settings_presenter(self):
     return mock.create_autospec(SummationSettingsPresenter, spec_set=True)
 def _summation_settings_with_save_directory(self, directory):
     mock_summation_settings = mock.create_autospec(SummationSettings, spec_set=True)
     mock_summation_settings.save_directory = directory
     return mock_summation_settings
Esempio n. 41
0
 def setUp(self):
     self.model = mock.create_autospec(data_model.FittingDataModel)
     self.view = mock.create_autospec(data_view.FittingDataView)
     self.presenter = data_presenter.FittingDataPresenter(self.model, self.view)
 def _make_mock_parent_view(self):
     mock_parent_view = mock.create_autospec(SANSDataProcessorGui, spec_set=True)
     mock_parent_view.instrument.to_string.return_value = 'LOQ'
     return mock_parent_view
Esempio n. 43
0
 def setUp(self):
     self.view = mock.create_autospec(view.CalibrationView)
     self.model = mock.create_autospec(model.CalibrationModel)
     self.view.get_cropping_widget.return_value = MagicMock()
     self.presenter = presenter.CalibrationPresenter(self.model, self.view)
     self.presenter.cropping_widget = MagicMock()
 def _make_mock_view(self):
     mock_view = mock.create_autospec(AddRunsPage, spec_set=True)
     mock_view.sum = FakeSignal()
     mock_view.outFileChanged = FakeSignal()
     mock_view.saveDirectoryClicked = FakeSignal()
     return mock_view
 def setUp(self):
     view = mock.create_autospec(AxisChangerView)
     self.acp = AxisChangerPresenter(view)
     self.view = self.acp.view
     self.slot = mock.Mock()
     self.bounds = mock.Mock()
 def _make_mock_run_selection(self, iterable):
     mock_runs = mock.create_autospec(RunSelection, spec_set=True)
     mock_runs.__iter__.return_value = list(iterable)
     return mock_runs
Esempio n. 47
0
def create_mock_settings_diagnostic_tab():
    view = mock.create_autospec(SettingsDiagnosticTab, spec_set=False)
    view.get_current_row = mock.MagicMock(return_value=3)
    return view
Esempio n. 48
0
def create_mock_beam_centre_tab():
    view = mock.create_autospec(BeamCentre, spec_set=False)
    view.r_min_line_edit = mock.Mock()
    view.r_max_line_edit = mock.Mock()
    return view
Esempio n. 49
0
def create_mock_masking_table():
    view = mock.create_autospec(MaskingTable, spec_set=False)
    view.get_current_row = mock.MagicMock(return_value=3)
    return view
Esempio n. 50
0
def create_mock_view(user_file_path, batch_file_path=None, row_user_file_path=""):
    get_cell_mock_with_path = partial(get_cell_mock, user_file_path=row_user_file_path)

    view = mock.create_autospec(SANSDataProcessorGui, spec_set=False)
    view.get_user_file_path = mock.Mock(return_value=user_file_path)
    view.get_cell = mock.MagicMock(side_effect=get_cell_mock_with_path)
    view.get_batch_file_path = mock.MagicMock(return_value=batch_file_path)
    view.get_number_of_rows = mock.MagicMock(return_value=2)

    # Add the settings diagnostic mock
    settings_diagnostic_tab = create_mock_settings_diagnostic_tab()
    view.settings_diagnostic_tab = settings_diagnostic_tab

    # Add the masking table view
    masking_table = create_mock_masking_table()
    view.masking_table = masking_table

    # Add the beam centre view
    beam_centre = create_mock_beam_centre_tab()
    view.beam_centre = beam_centre

    # Add the data diagnostic tab
    diagnostic_page = create_mock_diagnostics_tab()
    view.diagnostic_page = diagnostic_page

    view.halt_process_flag = mock.MagicMock()

    # Mock objects used in the properties handler
    view.user_file_line_edit = mock.Mock()

    # Mock the add runs presenter
    view.add_runs_presenter = mock.Mock()

    # ---------------------
    # Mocking properties
    # ---------------------
    _event_slices = mock.PropertyMock(return_value="")
    type(view).event_slices = _event_slices

    _merge_scale = mock.PropertyMock(return_value=1.)
    type(view).merge_scale = _merge_scale

    _merge_shift = mock.PropertyMock(return_value=0.)
    type(view).merge_shift = _merge_shift

    _merge_q_range_start = mock.PropertyMock(return_value=None)
    type(view).merge_q_range_start = _merge_q_range_start

    _merge_q_range_stop = mock.PropertyMock(return_value=None)
    type(view).merge_q_range_stop = _merge_q_range_stop

    _merge_q_range_stop = mock.PropertyMock(return_value=None)
    type(view).merge_q_range_stop = _merge_q_range_stop

    _merge_min = mock.PropertyMock(return_value=None)
    type(view).merge_min = _merge_min

    _merge_max = mock.PropertyMock(return_value=None)
    type(view).merge_max = _merge_max

    _sample_height = mock.PropertyMock(return_value=None)
    type(view).sample_height = _sample_height

    _sample_width = mock.PropertyMock(return_value=None)
    type(view).sample_width = _sample_width

    _sample_thickness = mock.PropertyMock(return_value=None)
    type(view).sample_thickness = _sample_thickness

    _sample_shape = mock.PropertyMock(return_value=None)
    type(view).sample_shape = _sample_shape

    _pixel_adjustment_det_1 = mock.PropertyMock(return_value="")
    type(view).pixel_adjustment_det_1 = _pixel_adjustment_det_1

    _pixel_adjustment_det_2 = mock.PropertyMock(return_value="")
    type(view).pixel_adjustment_det_2 = _pixel_adjustment_det_2

    _wavelength_adjustment_det_1 = mock.PropertyMock(return_value="")
    type(view).wavelength_adjustment_det_1 = _wavelength_adjustment_det_1

    _wavelength_adjustment_det_2 = mock.PropertyMock(return_value="")
    type(view).wavelength_adjustment_det_2 = _wavelength_adjustment_det_2

    _gravity_extra_length = mock.PropertyMock(return_value=None)
    type(view).gravity_extra_length = _gravity_extra_length

    _q_resolution_source_h = mock.PropertyMock(return_value=None)
    type(view).q_resolution_source_h = _q_resolution_source_h

    _q_resolution_sample_h = mock.PropertyMock(return_value=None)
    type(view).q_resolution_sample_h = _q_resolution_sample_h

    _q_resolution_source_w = mock.PropertyMock(return_value=None)
    type(view).q_resolution_source_w = _q_resolution_source_w

    _q_resolution_sample_w = mock.PropertyMock(return_value=None)
    type(view).q_resolution_sample_w = _q_resolution_sample_w

    _phi_limit_min = mock.PropertyMock(return_value=None)
    type(view).phi_limit_min = _phi_limit_min

    _phi_limit_max = mock.PropertyMock(return_value=None)
    type(view).phi_limit_max = _phi_limit_max

    _phi_limit_max = mock.PropertyMock(return_value=None)
    type(view).phi_limit_max = _phi_limit_max

    _q_1d_step = mock.PropertyMock(return_value=.001)
    type(view).q_1d_step = _q_1d_step

    _q_1d_step_type = mock.PropertyMock(return_value=RangeStepType.Lin)
    type(view)._q_1d_step_type = _q_1d_step_type

    _output_mode = mock.PropertyMock(return_value=OutputMode.PublishToADS)
    type(view).output_mode = _output_mode

    _wavelength_range = mock.PropertyMock(return_value='')
    type(view).wavelength_range = _wavelength_range

    _instrument = mock.PropertyMock(return_value=SANSInstrument.SANS2D)
    type(view).instrument = _instrument

    return view, settings_diagnostic_tab, masking_table
Esempio n. 51
0
def create_mock_diagnostics_tab():
    view = mock.create_autospec(DiagnosticsPage, spec_set=False)
    return view
Esempio n. 52
0
    def test_that_closing_with_a_plot_will_close_the_window(self):
        self.gui.plot_window = mock.create_autospec(MultiPlotWindow)
        self.gui.closeEvent(QCloseEvent())

        self.assertEqual(self.gui.plot_window.closeEvent.call_count, 1)
Esempio n. 53
0
 def setUp(self):
     self.pres = mock.create_autospec(QuickEditPresenter)
     self.widget = QuickEditWidget()
     self.slot = mock.Mock()
     self.widget.set_mock(self.pres)
Esempio n. 54
0
def create_mock_settings_diagnostic_tab():
    view = mock.create_autospec(SettingsDiagnosticTab, spec_set=False)
    view.get_current_row = mock.MagicMock(return_value=3)
    return view
Esempio n. 55
0
def create_mock_masking_table():
    view = mock.create_autospec(MaskingTable, spec_set=False)
    view.get_current_row = mock.MagicMock(return_value=3)
    return view
Esempio n. 56
0
def create_mock_beam_centre_tab():
    view = mock.create_autospec(BeamCentre, spec_set=False)
    view.r_min_line_edit = mock.Mock()
    view.r_max_line_edit = mock.Mock()
    return view
Esempio n. 57
0
    def test_plot_line_once_calls_correct_multiplot_function(self):
        self.gui.plotting = mock.create_autospec(MultiPlotWidget)
        self.gui._plot_line_once('GE1', 1.0, 'label', 'C0')

        self.assertEqual(self.gui.plotting.add_vline_and_annotate.call_count, 1)
 def _make_mock_settings(self):
     return mock.create_autospec(SummationSettings)