コード例 #1
0
    def test_that_subscribers_notified_when_instrument_changed(self):
        observer = Observer()
        observer.update = mock.MagicMock()
        self.data_context.instrumentNotifier.add_subscriber(observer)

        self.view.set_instrument('MUSR', block=True)
        self.view.set_instrument('CHRONUS')

        observer.update.assert_called_once_with(self.data_context.instrumentNotifier, 'CHRONUS')
コード例 #2
0
    def test_that_subscribers_notified_when_instrument_changed(self):
        observer = Observer()
        observer.update = mock.MagicMock()
        self.context.instrumentNotifier.add_subscriber(observer)

        self.view.set_instrument('MUSR', block=True)
        self.view.set_instrument('CHRONUS')

        observer.update.assert_called_once_with(
            self.context.instrumentNotifier, 'CHRONUS')
コード例 #3
0
    def test_that_signal_is_not_sent_if_item_updated_to_same_value(self):
        context = MuonGuiContext()
        observer = Observer()
        observer.update = mock.MagicMock()
        context.add_subscriber(observer)
        context.update({'FirstGoodData': 12.0})

        context.update_and_send_signal(FirstGoodData=12.0)

        observer.update.assert_not_called()
コード例 #4
0
    def test_that_signal_is_not_sent_if_item_updated_to_same_value(self):
        context = MuonGuiContext()
        observer = Observer()
        observer.update = mock.MagicMock()
        context.add_subscriber(observer)
        context.update({'FirstGoodData': 12.0})

        context.update_and_send_signal(FirstGoodData=12.0)

        observer.update.assert_not_called()
コード例 #5
0
    def test_that_signal_is_sent_when_item_updates(self):
        context = MuonGuiContext()
        observer = Observer()
        observer.update = mock.MagicMock()

        context.add_subscriber(observer)

        context.update_and_send_signal(FirstGoodData=12.0)

        observer.update.assert_called_once_with(context.gui_variables_notifier, None)
コード例 #6
0
    def test_that_signal_is_sent_when_item_updates(self):
        context = MuonGuiContext()
        observer = Observer()
        observer.update = mock.MagicMock()

        context.add_subscriber(observer)

        context.update_and_send_signal(FirstGoodData=12.0)

        observer.update.assert_called_once_with(context.gui_variables_notifier,
                                                {'FirstGoodData': 12.0})
コード例 #7
0
    def test_that_changeing_alpha_correctly_updates_model(self):
        self.view.grouppair_selector.setCurrentIndex(4)
        observer = Observer()
        observer.update = mock.MagicMock()
        self.presenter.pairAlphaNotifier.add_subscriber(observer)

        self.view.alpha_edit.setText('0.87')
        self.view.alpha_edit.editingFinished.emit()

        self.assertEqual(self.model.get_alpha('test_pair'), 0.87)
        observer.update.assert_called_once_with(self.presenter.pairAlphaNotifier, None)
コード例 #8
0
    def test_that_changeing_alpha_correctly_updates_model(self):
        self.view.grouppair_selector.setCurrentIndex(4)
        observer = Observer()
        observer.update = mock.MagicMock()
        self.presenter.pairAlphaNotifier.add_subscriber(observer)

        self.view.alpha_edit.setText('0.87')
        self.view.alpha_edit.editingFinished.emit()

        self.assertEqual(self.model.get_alpha('test_pair'), 0.87)
        observer.update.assert_called_once_with(
            self.presenter.pairAlphaNotifier, None)
コード例 #9
0
    def setUp(self):
        setup_context_for_tests(self)
        self.gui_variable_observer = Observer()
        self.gui_variable_observer.update = mock.MagicMock()
        self.gui_context.gui_variables_notifier.add_subscriber(
            self.gui_variable_observer)
        self.data_context.instrument = 'CHRONUS'
        self.gui_variable_observer = Observer()
        self.gui_variable_observer.update = mock.MagicMock()
        self.gui_context.gui_variables_notifier.add_subscriber(
            self.gui_variable_observer)

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

        load_result, run, filename, _ = load_workspace_from_filename(filepath)

        self.loaded_data.add_data(workspace=load_result,
                                  run=[run],
                                  filename=filename,
                                  instrument='CHRONUS')
        self.data_context.current_runs = [[run]]
        self.context.update_current_data()
コード例 #10
0
    def setUp(self):
        self.obj = QWidget()
        setup_context_for_tests(self)
        self.gui_variable_observer = Observer()

        self.gui_context.gui_variables_notifier.add_subscriber(
            self.gui_variable_observer)
        self.data_context.instrument = 'MUSR'
        self.view = InstrumentWidgetView(self.obj)
        self.view.set_instrument('MUSR', block=True)
        self.model = InstrumentWidgetModel(self.context)
        self.presenter = InstrumentWidgetPresenter(self.view, self.model)

        self.view.warning_popup = mock.MagicMock()
        self.view.instrument_changed_warning = mock.MagicMock(return_value=1)
        self.gui_variable_observer.update = mock.MagicMock()
コード例 #11
0
    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.gui_variable_observer = Observer()

        self.gui_context.gui_variables_notifier.add_subscriber(self.gui_variable_observer)
        self.model = GroupingTabModel(context=self.context)
        self.view = GroupingTableView(parent=self.obj)
        self.presenter = GroupingTablePresenter(self.view, self.model)

        self.view.enter_group_name = mock.Mock(side_effect=group_name())
        self.view.warning_popup = mock.Mock()
        self.gui_variable_observer.update = mock.MagicMock()
コード例 #12
0
 def __init__(self, callback):
     Observer.__init__(self)
     self.callback = callback
コード例 #13
0
 def __init__(self, outer):
     Observer.__init__(self)
     self.outer = outer
コード例 #14
0
 def __init__(self, callback):
     Observer.__init__(self)
     self.callback = callback
コード例 #15
0
 def __init__(self, outer):
     Observer.__init__(self)
     self.outer = outer