From bd5dfe920bf0823224cb59cd3288aa28730132d2 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 31 Jan 2017 17:41:35 +0000 Subject: [PATCH 1/2] fix bug 1660473 --- openlp/core/ui/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 34d41562a..b31211797 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -189,7 +189,7 @@ class Ui_MainWindow(object): triggers=self.service_manager_contents.on_load_service_clicked) self.file_save_item = create_action(main_window, 'fileSaveItem', icon=':/general/general_save.png', can_shortcuts=True, category=UiStrings().File, - triggers=self.service_manager_contents.save_file) + triggers=self.service_manager_contents.decide_save_method) self.file_save_as_item = create_action(main_window, 'fileSaveAsItem', can_shortcuts=True, category=UiStrings().File, triggers=self.service_manager_contents.save_file_as) From a5c9ded7577dfad7122fe3a26511e1e6e147f800 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 31 Jan 2017 19:07:54 +0000 Subject: [PATCH 2/2] fix tests --- .../openlp_core_ui/test_aboutform.py | 69 ++++++++++++------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/tests/functional/openlp_core_ui/test_aboutform.py b/tests/functional/openlp_core_ui/test_aboutform.py index ddba5ffcf..2cd0fadbf 100644 --- a/tests/functional/openlp_core_ui/test_aboutform.py +++ b/tests/functional/openlp_core_ui/test_aboutform.py @@ -22,36 +22,53 @@ """ Package to test the openlp.core.ui.firsttimeform package. """ -from unittest.mock import patch +from unittest import TestCase from openlp.core.ui.aboutform import AboutForm - -@patch('openlp.core.ui.aboutform.get_application_version') -def test_create_about_form(mocked_get_application_version): - """ - Test creating an about form - """ - # GIVEN: An application version with a build number - mocked_get_application_version.return_value = {'version': '3.1.1', 'build': '3000'} - - # WHEN: The about form is created - about_form = AboutForm(None) - - # THEN: The correct version information should be in the dialog - assert 'OpenLP 3.1.1 build 3000' in about_form.about_text_edit.toPlainText() +from tests.functional import patch +from tests.helpers.testmixin import TestMixin -@patch('openlp.core.ui.aboutform.webbrowser') -def test_on_volunteer_button_clicked(mocked_webbrowser): - """ - Test that clicking on the "Volunteer" button opens a web page. - """ - # GIVEN: A new About dialog and a mocked out webbrowser module - about_form = AboutForm(None) +class TestAboutForm(TestCase, TestMixin): - # WHEN: The "Volunteer" button is "clicked" - about_form.on_volunteer_button_clicked() + @patch('openlp.core.ui.aboutform.get_application_version') + def test_create_about_form(self, mocked_get_application_version): + """ + Test creating an about form + """ + # GIVEN: An application version with a build number + mocked_get_application_version.return_value = {'version': '3.1.1', 'build': '3000'} - # THEN: A web browser is opened - mocked_webbrowser.open_new.assert_called_with('http://openlp.org/en/contribute') + # WHEN: The about form is created + about_form = AboutForm(None) + + # THEN: The correct version information should be in the dialog + assert 'OpenLP 3.1.1 build 3000' in about_form.about_text_edit.toPlainText() + + @patch('openlp.core.ui.aboutform.webbrowser') + def test_on_volunteer_button_clicked(self, mocked_webbrowser): + """ + Test that clicking on the "Volunteer" button opens a web page. + """ + # GIVEN: A new About dialog and a mocked out webbrowser module + about_form = AboutForm(None) + + # WHEN: The "Volunteer" button is "clicked" + about_form.on_volunteer_button_clicked() + + # THEN: A web browser is opened + mocked_webbrowser.open_new.assert_called_with('http://openlp.org/en/contribute') + + def test_about_form_date_test(self): + """ + Test that the copyright date is included correctly + """ + # GIVEN: A correct application date + # WHEN: The about form is created + about_form = AboutForm(None) + license_text = about_form.license_text_edit.toPlainText() + + # THEN: The date should be in the text twice. + self.assertTrue(license_text.count('2017', 0) == 2, + "The text string should be added twice to the license string")