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')
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')
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()
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()
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)
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})
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)
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)
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()
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()
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()
def __init__(self, callback): Observer.__init__(self) self.callback = callback
def __init__(self, outer): Observer.__init__(self) self.outer = outer
def __init__(self, callback): Observer.__init__(self) self.callback = callback
def __init__(self, outer): Observer.__init__(self) self.outer = outer