def setUp(self):
        # Store an empty widget to parent all the views, and ensure they are deleted correctly
        self.obj = QWidget()
        ConfigService['default.instrument'] = 'MUSR'

        setup_context_for_tests(self)
        self.context.instrument = 'MUSR'
        self.load_file_view = BrowseFileWidgetView(self.obj)
        self.load_run_view = LoadRunWidgetView(self.obj)
        self.load_file_model = BrowseFileWidgetModel(self.loaded_data,
                                                     self.context)
        self.load_run_model = LoadRunWidgetModel(self.loaded_data,
                                                 self.context)

        self.view = LoadWidgetView(parent=self.obj,
                                   load_file_view=self.load_file_view,
                                   load_run_view=self.load_run_view)
        self.presenter = LoadWidgetPresenter(
            self.view, LoadWidgetModel(self.loaded_data, self.context))
        self.presenter.set_load_file_widget(
            BrowseFileWidgetPresenter(self.load_file_view,
                                      self.load_file_model))
        self.presenter.set_load_run_widget(
            LoadRunWidgetPresenter(self.load_run_view, self.load_run_model))

        self.presenter.load_file_widget._view.warning_popup = mock.MagicMock()
        self.presenter.load_run_widget._view.warning_popup = mock.MagicMock()

        self.view.multiple_loading_check.setCheckState(1)
        self.presenter.handle_multiple_files_option_changed()

        self.runs = [15196, 15197]
        self.workspaces = [self.create_fake_workspace(1) for _ in self.runs]
        self.filenames = FileFinder.findRuns(
            'MUSR00015196.nxs, MUSR00015197.nxs')
Exemple #2
0
    def __init__(self, loaded_data, context, parent):
        # set up the views
        self.load_file_view = BrowseFileWidgetView(parent)
        self.load_file_view.hide_browse()
        self.load_run_view = LoadRunWidgetView(parent)
        self.load_run_view.hide_current_run_button()
        self.load_run_view.hide_instrument_label()
        self.load_widget_view = LoadWidgetView(
            parent=parent,
            load_file_view=self.load_file_view,
            load_run_view=self.load_run_view)
        self.load_widget = LoadWidgetPresenterEA(
            self.load_widget_view, LoadWidgetModel(loaded_data, context))

        self.file_widget = BrowseFileWidgetPresenter(
            self.load_file_view, BrowseFileWidgetModel(loaded_data, context))
        self.run_widget = LoadRunWidgetPresenterEA(
            self.load_run_view, LoadRunWidgetModel(loaded_data, context))

        self.load_widget.set_load_file_widget(self.file_widget)
        self.load_widget.set_load_run_widget(self.run_widget)

        self.load_widget.set_current_instrument(
            context.data_context.instrument)

        self.run_widget.updated_directory.add_subscriber(
            self.file_widget.updated_file_path)
    def setUp(self):
        self._qapp = mock_widget.mockQapp()

        # Store an empty widget to parent all the views, and ensure they are deleted correctly
        self.obj = QtGui.QWidget()

        self.popup_patcher = mock.patch('Muon.GUI.Common.thread_model.warning')
        self.addCleanup(self.popup_patcher.stop)
        self.popup_mock = self.popup_patcher.start()

        self.load_patcher = mock.patch(
            'Muon.GUI.Common.load_file_widget.model.load_utils.load_workspace_from_filename'
        )
        self.addCleanup(self.load_patcher.stop)
        self.load_mock = self.load_patcher.start()

        self.load_run_patcher = mock.patch(
            'Muon.GUI.Common.load_run_widget.load_run_model.load_utils.load_workspace_from_filename'
        )
        self.addCleanup(self.load_run_patcher.stop)
        self.load_run_mock = self.load_run_patcher.start()

        self.data = MuonLoadData()
        self.context = MuonDataContext(self.data)
        self.context.instrument = 'EMU'
        self.load_file_view = BrowseFileWidgetView(self.obj)
        self.load_run_view = LoadRunWidgetView(self.obj)
        self.load_file_model = BrowseFileWidgetModel(self.data, self.context)
        self.load_run_model = LoadRunWidgetModel(self.data, self.context)

        self.model = LoadWidgetModel(self.data, self.context)
        self.view = LoadWidgetView(parent=self.obj,
                                   load_run_view=self.load_run_view,
                                   load_file_view=self.load_file_view)

        self.presenter = LoadWidgetPresenter(view=self.view, model=self.model)
        self.presenter.set_load_file_widget(
            BrowseFileWidgetPresenter(self.load_file_view,
                                      self.load_file_model))
        self.presenter.set_load_run_widget(
            LoadRunWidgetPresenter(self.load_run_view, self.load_run_model))
        self.presenter.load_run_widget.set_current_instrument('EMU')

        self.presenter.load_file_widget._view.warning_popup = mock.MagicMock()
        self.presenter.load_run_widget._view.warning_popup = mock.MagicMock()

        self.load_file_view.show_file_browser_and_return_selection = mock.Mock(
            return_value=["C:\\dir1\\EMU0001234.nxs"])
        self.workspace_mock = self.create_fake_workspace(1)
        self.load_mock.return_value = (self.workspace_mock, 1234,
                                       "C:\\dir1\\EMU0001234.nxs")
        self.load_run_mock.return_value = (self.workspace_mock, 1234,
                                           "C:\\dir1\\EMU0001234.nxs")

        self.presenter.load_file_widget.on_browse_button_clicked()
        self.wait_for_thread(self.presenter.load_file_widget._load_thread)

        self.mock_loading_to_throw()
        file_utils.get_current_run_filename = mock.Mock(
            return_value="EMU0001234.nxs")
    def setUp(self):
        # Store an empty widget to parent all the views, and ensure they are deleted correctly
        self.obj = QWidget()

        setup_context_for_tests(self)
        self.context.instrument = 'EMU'
        self.load_file_view = BrowseFileWidgetView(self.obj)
        self.load_run_view = LoadRunWidgetView(self.obj)
        self.load_file_model = BrowseFileWidgetModel(self.loaded_data,
                                                     self.context)
        self.load_run_model = LoadRunWidgetModel(self.loaded_data,
                                                 self.context)

        self.presenter = LoadWidgetPresenter(
            LoadWidgetView(parent=self.obj,
                           load_file_view=self.load_file_view,
                           load_run_view=self.load_run_view),
            LoadWidgetModel(self.loaded_data, self.context))
        self.presenter.set_load_file_widget(
            BrowseFileWidgetPresenter(self.load_file_view,
                                      self.load_file_model))
        self.presenter.set_load_run_widget(
            LoadRunWidgetPresenter(self.load_run_view, self.load_run_model))

        self.filepath = FileFinder.findRuns('MUSR00022725.nxs')[0]

        self.load_patcher = mock.patch(
            'Muon.GUI.Common.load_file_widget.model.load_utils.load_workspace_from_filename'
        )
        self.addCleanup(self.load_patcher.stop)
        self.load_mock = self.load_patcher.start()

        self.load_run_patcher = mock.patch(
            'Muon.GUI.Common.load_run_widget.load_run_model.load_utils.load_workspace_from_filename'
        )
        self.addCleanup(self.load_run_patcher.stop)
        self.load_run_mock = self.load_run_patcher.start()

        self.mock_workspace = self.create_fake_workspace(1)
        self.mock_loading_from_browse(self.mock_workspace,
                                      "C:\dir1\dir2\dir3\EMU0001234.nxs", 1234)
        file_utils.get_current_run_filename = mock.Mock(
            return_value="C:\dir1\dir2\dir3\EMU0001234.nxs")

        self.presenter.load_file_widget._view.warning_popup = mock.MagicMock()
        self.presenter.load_run_widget._view.warning_popup = mock.MagicMock()

        self.popup_patcher = mock.patch('Muon.GUI.Common.thread_model.warning')
        self.addCleanup(self.popup_patcher.stop)
        self.popup_mock = self.popup_patcher.start()

        def setGroupAndPairsToEmptyList(grouping_context):
            grouping_context._groups = []
            grouping_context._pairs = []

        self.group_context.reset_group_and_pairs_to_default = mock.MagicMock(
            side_effect=setGroupAndPairsToEmptyList(self.group_context))
Exemple #5
0
    def setUp(self):
        self._qapp = mock_widget.mockQapp()
        # Store an empty widget to parent all the views, and ensure they are deleted correctly
        self.obj = QtGui.QWidget()

        self.data = MuonLoadData()
        self.context = MuonDataContext(self.data)
        self.context.instrument = 'EMU'
        self.load_file_view = BrowseFileWidgetView(self.obj)
        self.load_run_view = LoadRunWidgetView(self.obj)
        self.load_file_model = BrowseFileWidgetModel(self.data, self.context)
        self.load_run_model = LoadRunWidgetModel(self.data, self.context)

        self.presenter = LoadWidgetPresenter(
            LoadWidgetView(parent=self.obj,
                           load_file_view=self.load_file_view,
                           load_run_view=self.load_run_view),
            LoadWidgetModel(self.data, self.context))
        self.presenter.set_load_file_widget(
            BrowseFileWidgetPresenter(self.load_file_view,
                                      self.load_file_model))
        self.presenter.set_load_run_widget(
            LoadRunWidgetPresenter(self.load_run_view, self.load_run_model))

        self.filepath = FileFinder.findRuns('MUSR00022725.nxs')[0]

        self.load_patcher = mock.patch(
            'Muon.GUI.Common.load_file_widget.model.load_utils.load_workspace_from_filename'
        )
        self.addCleanup(self.load_patcher.stop)
        self.load_mock = self.load_patcher.start()

        self.load_run_patcher = mock.patch(
            'Muon.GUI.Common.load_run_widget.load_run_model.load_utils.load_workspace_from_filename'
        )
        self.addCleanup(self.load_run_patcher.stop)
        self.load_run_mock = self.load_run_patcher.start()

        self.mock_workspace = self.create_fake_workspace(1)
        self.mock_loading_from_browse(self.mock_workspace,
                                      "C:\dir1\dir2\dir3\EMU0001234.nxs", 1234)
        file_utils.get_current_run_filename = mock.Mock(
            return_value="C:\dir1\dir2\dir3\EMU0001234.nxs")

        self.presenter.load_file_widget._view.warning_popup = mock.MagicMock()
        self.presenter.load_run_widget._view.warning_popup = mock.MagicMock()

        self.popup_patcher = mock.patch('Muon.GUI.Common.thread_model.warning')
        self.addCleanup(self.popup_patcher.stop)
        self.popup_mock = self.popup_patcher.start()
Exemple #6
0
    def __init__(self, loaded_data, context, parent):
        # set up the views
        self.load_file_view = BrowseFileWidgetView(parent)
        self.load_run_view = LoadRunWidgetView(parent)
        self.load_widget_view = LoadWidgetView(parent=parent,
                                               load_file_view=self.load_file_view,
                                               load_run_view=self.load_run_view)
        self.load_widget = LoadWidgetPresenter(self.load_widget_view,
                                               LoadWidgetModel(loaded_data, context))

        self.file_widget = BrowseFileWidgetPresenter(self.load_file_view, BrowseFileWidgetModel(loaded_data, context))
        self.run_widget = LoadRunWidgetPresenter(self.load_run_view, LoadRunWidgetModel(loaded_data, context))

        self.load_widget.set_load_file_widget(self.file_widget)
        self.load_widget.set_load_run_widget(self.run_widget)

        self.load_widget.set_current_instrument(context.instrument)
    def setUp(self):
        # Store an empty widget to parent all the views, and ensure they are deleted correctly
        self.obj = QWidget()

        setup_context_for_ea_tests(self)
        self.load_file_view = BrowseFileWidgetView(self.obj)
        self.load_run_view = LoadRunWidgetView(self.obj)
        self.load_run_view.set_current_instrument = mock.Mock()
        self.view = LoadWidgetView(parent=self.obj,
                                   load_file_view=self.load_file_view,
                                   load_run_view=self.load_run_view)
        self.model = LoadWidgetModel(self.loaded_data, self.context)
        self.model.instrument = mock.Mock()
        self.presenter = LoadWidgetPresenterEA(self.view, self.model)
        loaded_data = mock.Mock()
        context = mock.Mock()
        self.run_widget = LoadRunWidgetPresenterEA(
            self.load_run_view, LoadRunWidgetModel(loaded_data, context))
        self.presenter.set_load_run_widget(self.run_widget)
Exemple #8
0
    def __init__(self, loaded_data, context, parent):
        # set up the views
        self.load_file_view = BrowseFileWidgetView(parent)
        self.load_run_view = LoadRunWidgetView(parent)
        self.load_widget_view = LoadWidgetView(
            parent=parent,
            load_file_view=self.load_file_view,
            load_run_view=self.load_run_view)
        self.load_widget = LoadWidgetPresenter(
            self.load_widget_view, LoadWidgetModel(loaded_data, context))

        self.file_widget = BrowseFileWidgetPresenter(
            self.load_file_view, BrowseFileWidgetModel(loaded_data, context))
        self.run_widget = LoadRunWidgetPresenter(
            self.load_run_view, LoadRunWidgetModel(loaded_data, context))

        self.load_widget.set_load_file_widget(self.file_widget)
        self.load_widget.set_load_run_widget(self.run_widget)

        self.load_widget.set_current_instrument(
            context.data_context.instrument)

        context.update_view_from_model_notifier.add_subscriber(
            self.load_widget.update_view_from_model_observer)