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, context):

        self.group_tab_model = GroupingTabModel(context)

        self.grouping_table_view = GroupingTableView()
        self.grouping_table_widget = GroupingTablePresenter(
            self.grouping_table_view, self.group_tab_model)

        self.pairing_table_view = PairingTableView()
        self.pairing_table_widget = PairingTablePresenter(
            self.pairing_table_view, self.group_tab_model)

        self.group_tab_view = GroupingTabView(self.grouping_table_view,
                                              self.pairing_table_view)
        self.group_tab_presenter = GroupingTabPresenter(
            self.group_tab_view, self.group_tab_model,
            self.grouping_table_widget, self.pairing_table_widget)
    def setUp(self):
        self.obj = QWidget()

        self.loaded_data = MuonLoadData()

        setup_context_for_tests(self)

        self.model = GroupingTabModel(context=self.context)

        self.grouping_table_view = GroupingTableView()
        self.grouping_table_widget = GroupingTablePresenter(
            self.grouping_table_view, self.model)

        self.pairing_table_view = PairingTableView()
        self.pairing_table_widget = PairingTablePresenter(
            self.pairing_table_view, self.model)

        self.diff_widget = DifferencePresenter(self.model)
        self.diff_widget.group_view.enter_diff_name = mock.Mock(
            side_effect=diff_name())
        self.diff_widget.pair_view.enter_diff_name = mock.Mock(
            side_effect=diff_name())

        self.grouping_table_view.warning_popup = mock.MagicMock()
        self.pairing_table_view.warning_popup = mock.MagicMock()

        self.add_three_groups()
        self.add_two_pairs()

        self.view = GroupingTabView(self.grouping_table_view,
                                    self.pairing_table_view,
                                    self.diff_widget.view)
        self.presenter = GroupingTabPresenter(self.view, self.model,
                                              self.grouping_table_widget,
                                              self.pairing_table_widget,
                                              self.diff_widget)

        self.presenter.create_update_thread = mock.MagicMock(
            return_value=mock.MagicMock())
        self.presenter.pairing_table_widget.handle_add_pair_button_clicked = mock.MagicMock(
        )
        self.view.display_warning_box = mock.MagicMock()
        self.grouping_table_view.warning_popup = mock.MagicMock()
        self.pairing_table_view.warning_popup = mock.MagicMock()
Beispiel #4
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.presenter = DifferencePresenter(self.model)

        # Mock user input for getting diff name
        self.presenter.group_view.enter_diff_name = mock.Mock(side_effect=enter_diff_name_side_effect())
        self.presenter.pair_view.enter_diff_name = mock.Mock(side_effect=enter_diff_name_side_effect())

        # Mock warning methods
        self.presenter.group_view.warning_popup = mock.Mock()
        self.presenter.pair_view.warning_popup = mock.Mock()
Beispiel #5
0
    def __init__(self, context):

        self.group_tab_model = GroupingTabModel(context)

        self.grouping_table_view = GroupingTableView()
        self.grouping_table_widget = GroupingTablePresenter(
            self.grouping_table_view, self.group_tab_model)

        self.pairing_table_view = PairingTableView()
        self.pairing_table_widget = PairingTablePresenter(
            self.pairing_table_view, self.group_tab_model)

        self.group_tab_view = GroupingTabView(self.grouping_table_view,
                                              self.pairing_table_view)
        self.group_tab_presenter = GroupingTabPresenter(
            self.group_tab_view, self.group_tab_model,
            self.grouping_table_widget, self.pairing_table_widget)

        context.update_view_from_model_notifier.add_subscriber(
            self.group_tab_presenter.update_view_from_model_observer)
    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.loaded_data = MuonLoadData()
        self.data_context = MuonDataContext(self.loaded_data)
        self.gui_context = MuonGuiContext()
        self.group_context = MuonGroupPairContext(
            self.data_context.check_group_contains_valid_detectors)
        self.context = MuonContext(muon_data_context=self.data_context,
                                   muon_group_context=self.group_context,
                                   muon_gui_context=self.gui_context)

        self.model = GroupingTabModel(context=self.context)

        self.grouping_table_view = GroupingTableView(parent=self.obj)
        self.grouping_table_widget = GroupingTablePresenter(
            self.grouping_table_view, self.model)

        self.pairing_table_view = PairingTableView(parent=self.obj)
        self.pairing_table_widget = PairingTablePresenter(
            self.pairing_table_view, self.model)

        self.add_three_groups()
        self.add_two_pairs()

        self.view = GroupingTabView(self.grouping_table_view,
                                    self.pairing_table_view,
                                    parent=self.obj)
        self.presenter = GroupingTabPresenter(self.view, self.model,
                                              self.grouping_table_widget,
                                              self.pairing_table_widget)

        self.presenter.create_update_thread = mock.MagicMock(
            return_value=mock.MagicMock())
        self.view.display_warning_box = mock.MagicMock()
        self.grouping_table_view.warning_popup = mock.MagicMock()
        self.pairing_table_view.warning_popup = mock.MagicMock()
Beispiel #7
0
    def setUp(self):
        self.loaded_data = MuonLoadData()

        self.context = setup_context(False)

        self.data_context = self.context.data_context
        self.gui_context = self.context.gui_context
        self.group_context = self.context.group_pair_context

        self.model = GroupingTabModel(context=self.context)

        self.grouping_table_view = GroupingTableView()
        self.grouping_table_widget = GroupingTablePresenter(
            self.grouping_table_view, self.model)

        self.pairing_table_view = PairingTableView()
        self.pairing_table_widget = PairingTablePresenter(
            self.pairing_table_view, self.model)

        self.grouping_table_view.warning_popup = mock.MagicMock()
        self.pairing_table_view.warning_popup = mock.MagicMock()

        self.add_three_groups()
        self.add_two_pairs()

        self.view = GroupingTabView(self.grouping_table_view,
                                    self.pairing_table_view)
        self.presenter = GroupingTabPresenter(self.view, self.model,
                                              self.grouping_table_widget,
                                              self.pairing_table_widget)

        self.presenter.create_update_thread = mock.MagicMock(
            return_value=mock.MagicMock())
        self.view.display_warning_box = mock.MagicMock()
        self.grouping_table_view.warning_popup = mock.MagicMock()
        self.pairing_table_view.warning_popup = mock.MagicMock()
Beispiel #8
0
    def test_reset_group_and_pairs_to_default_for_no_loaded_runs(self):
        self.context.current_runs = []
        model = GroupingTabModel(self.context)

        status = model.reset_groups_and_pairs_to_default()
        self.assertEquals(status, "failed")