def test_action_current_row_changed(self):
        mock_view = MockSettingsView()
        p = SettingsPresenter(None, view=mock_view, general_settings=mock_view.general_settings)

        p.action_section_changed(0)

        # Currently this is not called, because we only have 1 view.
        # When more views are added this test WILL BREAK, and should be adapted
        # to check if the views are being switched correctly
        self.assertEqual(0, mock_view.container.replaceWidget.call_count)
    def test_action_save_settings_to_file(self):
        mock_view = MockSettingsView()
        mock_model = MagicMock()
        presenter = SettingsPresenter(None, view=mock_view, model=mock_model,
                                      general_settings=mock_view.general_settings,
                                      categories_settings=mock_view.categories_settings,
                                      plot_settings=mock_view.plot_settings,
                                      fitting_settings=mock_view.fitting_settings)

        presenter.action_save_settings_to_file()
        presenter.model.save_settings_to_file.assert_called_once_with("filename", presenter.all_properties)
    def test_action_current_row_changed(self):
        mock_view = MockSettingsView()
        p = SettingsPresenter(None,
                              view=mock_view,
                              general_settings=mock_view.general_settings)

        p.action_section_changed(0)

        # Currently this is not called, because we only have 1 view.
        # When more views are added this test WILL BREAK, and should be adapted
        # to check if the views are being switched correctly
        self.assertEqual(0, mock_view.container.replaceWidget.call_count)
Example #4
0
    def test_action_current_row_changed(self):
        mock_view = MockSettingsView()
        presenter = SettingsPresenter(None, view=mock_view,
                                      general_settings=mock_view.general_settings,
                                      categories_settings=mock_view.categories_settings,
                                      plot_settings=mock_view.plot_settings,
                                      fitting_settings=mock_view.fitting_settings)

        mock_view.sections.item = Mock()
        mock_view.sections.item().text = Mock(return_value = presenter.SETTINGS_TABS['categories_settings'])
        presenter.action_section_changed(1)

        self.assertEqual(1, mock_view.container.replaceWidget.call_count)
        self.assertEqual(mock_view.categories_settings.view, presenter.current)
    def test_default_view_shown(self):
        mock_view = MockSettingsView()
        SettingsPresenter(None,
                          view=mock_view,
                          general_settings=mock_view.general_settings)

        mock_view.container.addWidget.assert_called_once_with(
            mock_view.general_settings.view)
Example #6
0
    def test_default_view_shown(self):
        mock_view = MockSettingsView()
        SettingsPresenter(None, view=mock_view,
                          general_settings=mock_view.general_settings,
                          categories_settings=mock_view.categories_settings,
                          plot_settings=mock_view.plot_settings,
                          fitting_settings=mock_view.fitting_settings)

        expected_calls = [call(mock_view.general_settings.view), call(mock_view.categories_settings.view)]
        mock_view.container.addWidget.assert_has_calls(expected_calls)
Example #7
0
    def test_deletes_on_close(self):
        with MockWorkspaceWidget() as temp_widget:
            widget = SettingsPresenter(temp_widget)
            self.assert_widget_created()
            self.assert_widget_exists("GeneralSettings", expected_count=1)

            widget.view.close()

        QApplication.processEvents()

        self.assert_no_toplevel_widgets()
    def test_register_change_needs_restart(self):
        mock_view = MagicMock()
        mock_model = MagicMock()
        mock_parent = MagicMock()
        presenter = SettingsPresenter(mock_parent, view=mock_view, model = mock_model,
                                      general_settings=mock_view.general_settings,
                                      categories_settings=mock_view.categories_settings,
                                      plot_settings=mock_view.plot_settings,
                                      fitting_settings=mock_view.fitting_settings)

        settings_needing_restart = ["Setting one","Setting two"]
        for setting in settings_needing_restart:
            presenter.register_change_needs_restart(setting)
        presenter.view_closing()
        presenter.view.notify_changes_need_restart.assert_called_once_with(settings_needing_restart)
Example #9
0
 def open_settings_layout_window(self):
     settings = SettingsPresenter(self)
     settings.show()
     settings.general_settings.focus_layout_box()
Example #10
0
 def open_settings_window(self):
     settings = SettingsPresenter(self)
     settings.show()
Example #11
0
 def open_settings_window(self):
     settings = SettingsPresenter(self)
     settings.show()