class HomeTabRunInfoPresenterTest(unittest.TestCase):
    def setUp(self):
        self.obj = QWidget()
        setup_context_for_tests(self)
        self.data_context.instrument = 'MUSR'
        self.view = HomeRunInfoWidgetView(self.obj)
        self.model = HomeRunInfoWidgetModel(self.context)
        self.presenter = HomeRunInfoWidgetPresenter(self.view, self.model)

        self.view.warning_popup = mock.MagicMock()

    def tearDown(self):
        self.obj = None

    def test_runinfo_correct(self):
        file_path = FileFinder.findRuns('MUSR00022725.nxs')[0]
        ws, run, filename, _ = load_utils.load_workspace_from_filename(file_path)
        self.data_context._loaded_data.remove_data(run=run)
        self.data_context._loaded_data.add_data(run=[run], workspace=ws, filename=filename, instrument='MUSR')
        self.data_context.current_runs = [[22725]]
        self.context.update_current_data()
        test_pair = MuonPair('test_pair', 'top', 'bottom', alpha=0.75)
        self.group_context.add_pair(pair=test_pair)

        self.presenter.update_view_from_model()

        expected_string_list = ['Instrument:MUSR', 'Run:22725', 'Title:FeTeSeT=1F=100', 'Comment:FCfirstsample',
                                'Start:2009-03-24T04:18:58', 'End:2009-03-24T04:56:26', 'Counts(MEv):20.076704',
                                'GoodFrames:88540', 'CountsperGoodFrame:226.753',
                                'CountsperGoodFrameperdet:3.543', 'AverageTemperature(K):19.69992',
                                'SampleTemperature(K):1.0', 'SampleMagneticField(G):100.0']

        self.assertEqual(str(self.view.run_info_box.toPlainText()).replace(' ', '').splitlines(), expected_string_list)
class HomeTabRunInfoPresenterTest(unittest.TestCase):
    def setUp(self):
        self._qapp = mock_widget.mockQapp()
        self.obj = QtGui.QWidget()
        setup_context_for_tests(self)
        self.data_context.instrument = 'MUSR'
        self.view = HomeRunInfoWidgetView(self.obj)
        self.model = HomeRunInfoWidgetModel(self.context)
        self.presenter = HomeRunInfoWidgetPresenter(self.view, self.model)

        self.view.warning_popup = mock.MagicMock()

    def tearDown(self):
        self.obj = None

    def test_runinfo_correct(self):
        file_path = FileFinder.findRuns('MUSR00022725.nxs')[0]
        ws, run, filename = load_utils.load_workspace_from_filename(file_path)
        self.data_context._loaded_data.remove_data(run=run)
        self.data_context._loaded_data.add_data(run=[run], workspace=ws, filename=filename, instrument='MUSR')
        self.data_context.current_runs = [[22725]]
        self.context.update_current_data()
        test_pair = MuonPair('test_pair', 'top', 'bottom', alpha=0.75)
        self.group_context.add_pair(pair=test_pair)

        self.presenter.update_view_from_model()

        expected_string_list = ['Instrument:MUSR', 'Run:22725', 'Title:FeTeSeT=1F=100', 'Comment:FCfirstsample',
                                'Start:2009-03-24T04:18:58', 'End:2009-03-24T04:56:26', 'Counts(MEv):20.076704',
                                'GoodFrames:88540', 'CountsperGoodFrame:226.753',
                                'CountsperGoodFrameperdet:3.543', 'AverageTemperature(K):2.53386',
                                'SampleTemperature(K):1.0', 'SampleMagneticField(G):100.0']

        self.assertEqual(str(self.view.run_info_box.toPlainText()).replace(' ', '').splitlines(), expected_string_list)
    def setUp(self):
        self.obj = QWidget()
        setup_context_for_tests(self)
        self.data_context.instrument = 'MUSR'
        self.view = HomeRunInfoWidgetView(self.obj)
        self.model = HomeRunInfoWidgetModel(self.context)
        self.presenter = HomeRunInfoWidgetPresenter(self.view, self.model)

        self.view.warning_popup = mock.MagicMock()
    def setUp(self):
        self._qapp = mock_widget.mockQapp()
        self.obj = QtGui.QWidget()
        self.context = MuonDataContext()
        self.view = HomeRunInfoWidgetView(self.obj)
        self.model = HomeRunInfoWidgetModel(self.context)
        self.presenter = HomeRunInfoWidgetPresenter(self.view, self.model)

        self.view.warning_popup = mock.MagicMock()
Пример #5
0
    def __init__(self, context, parent):
        self.inst_view = InstrumentWidgetView(parent)
        self.grp_view = HomeGroupingWidgetView(parent)
        self.run_info_view = HomeRunInfoWidgetView(parent)
        self.plot_view = HomePlotWidgetView(parent)

        # keep a handle to the presenters of sub-widgets
        self.instrument_widget = InstrumentWidgetPresenter(self.inst_view,
                                                           InstrumentWidgetModel(context=context))
        self.group_widget = HomeGroupingWidgetPresenter(self.grp_view, HomeGroupingWidgetModel(context=context))
        self.run_info_widget = HomeRunInfoWidgetPresenter(self.run_info_view,
                                                          HomeRunInfoWidgetModel(context=context))
        self.plot_widget = HomePlotWidgetPresenter(self.plot_view, HomePlotWidgetModel(), context)
        self.home_tab_view = HomeTabView(parent=parent,
                                         widget_list=[self.inst_view,
                                                      self.grp_view,
                                                      self.plot_view,
                                                      self.run_info_view])
        self.home_tab_model = HomeTabModel(context=context)
        self.home_tab_widget = HomeTabPresenter(self.home_tab_view, self.home_tab_model,
                                                subwidgets=[self.instrument_widget,
                                                            self.group_widget,
                                                            self.plot_widget,
                                                            self.run_info_widget])

        context.update_view_from_model_notifier.add_subscriber(self.home_tab_widget.update_view_from_model_observer)
Пример #6
0
    def __init__(self, context, parent):
        self.inst_view = InstrumentWidgetView(parent)
        self.grp_view = HomeGroupingWidgetView(parent)
        self.plot_view = HomePlotWidgetView(parent)
        self.run_info_view = HomeRunInfoWidgetView(parent)

        # keep a handle to the presenters of sub-widgets
        self.instrument_widget = InstrumentWidgetPresenter(
            self.inst_view, InstrumentWidgetModel(muon_data=context))
        self.group_widget = HomeGroupingWidgetPresenter(
            self.grp_view, HomeGroupingWidgetModel(muon_data=context))
        self.plot_widget = HomePlotWidgetPresenter(self.plot_view,
                                                   HomePlotWidgetModel())
        self.run_info_widget = HomeRunInfoWidgetPresenter(
            self.run_info_view, HomeRunInfoWidgetModel(muon_data=context))

        self.home_tab_view = HomeTabView(parent=parent,
                                         widget_list=[
                                             self.inst_view, self.grp_view,
                                             self.plot_view, self.run_info_view
                                         ])
        self.home_tab_model = HomeTabModel(muon_data=context)
        self.home_tab_widget = HomeTabPresenter(self.home_tab_view,
                                                self.home_tab_model,
                                                subwidgets=[
                                                    self.instrument_widget,
                                                    self.group_widget,
                                                    self.plot_widget,
                                                    self.run_info_widget
                                                ])
    def setUp(self):
        self._qapp = mock_widget.mockQapp()
        self.obj = QtGui.QWidget()
        setup_context_for_tests(self)
        self.data_context.instrument = 'MUSR'
        self.view = HomeRunInfoWidgetView(self.obj)
        self.model = HomeRunInfoWidgetModel(self.context)
        self.presenter = HomeRunInfoWidgetPresenter(self.view, self.model)

        self.view.warning_popup = mock.MagicMock()