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')
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( 'mantidqtinterfaces.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( 'mantidqtinterfaces.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, r"C:\dir1\dir2\dir3\EMU0001234.nxs", 1234) file_utils.get_current_run_filename = mock.Mock( return_value=r"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( 'mantidqtinterfaces.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))
def setUp(self): # Store an empty widget to parent all the views, and ensure they are deleted correctly self.obj = QWidget() self.popup_patcher = mock.patch('mantidqtinterfaces.Muon.GUI.Common.thread_model.warning') self.addCleanup(self.popup_patcher.stop) self.popup_mock = self.popup_patcher.start() self.load_patcher = mock.patch( 'mantidqtinterfaces.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( 'mantidqtinterfaces.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() setup_context_for_tests(self) self.data_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.model = LoadWidgetModel(self.loaded_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", False) self.load_run_mock.return_value = (self.workspace_mock, 1234, "C:\\dir1\\EMU0001234.nxs", False) self.presenter.load_file_widget.on_browse_button_clicked() self.context.update_current_data = mock.MagicMock(return_value=([], [])) self.wait_for_thread(self.presenter.load_file_widget._load_thread) file_utils.get_current_run_filename = mock.Mock(return_value="EMU0001234.nxs")
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)