From 7c0157ed4be551d2c42cb84aa094d3069f59e3aa Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 4 Jul 2017 15:30:41 -0700 Subject: [PATCH] Remove all instances of 'OpenLP 2' and 'OpenLP 2.4' and fix one entry to be more descriptive --- openlp/core/common/uistrings.py | 5 +- openlp/core/ui/mainwindow.py | 6 +-- openlp/plugins/alerts/lib/alertstab.py | 2 +- openlp/plugins/remotes/lib/httprouter.py | 10 ++-- openlp/plugins/songs/lib/importer.py | 2 +- tests/functional/openlp_core/test_init.py | 50 ++++++++++++++++++- .../openlp_core_ui/test_mainwindow.py | 14 +++--- 7 files changed, 67 insertions(+), 22 deletions(-) diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 243e6016a..a5b76c6cf 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -120,9 +120,8 @@ class UiStrings(object): self.NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular') self.NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural') self.NoResults = translate('OpenLP.Ui', 'No Search Results') - self.OLP = translate('OpenLP.Ui', 'OpenLP') - self.OLPV2 = "{name} {version}".format(name=self.OLP, version="2") - self.OLPV2x = "{name} {version}".format(name=self.OLP, version="2.4") + self.OpenLP = translate('OpenLP.Ui', 'OpenLP') + self.OpenLPv2AndUp = translate('OpenLP.Ui', 'OpenLP 2.0 and up') self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?') self.OpenService = translate('OpenLP.Ui', 'Open service.') self.OptionalShowInFooter = translate('OpenLP.Ui', 'Optional, this will be displayed in footer.') diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 1ea61b5a5..e9a68ccaa 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -370,7 +370,7 @@ class Ui_MainWindow(object): """ Set up the translation system """ - main_window.setWindowTitle(UiStrings().OLP) + main_window.setWindowTitle(UiStrings().OpenLP) self.file_menu.setTitle(translate('OpenLP.MainWindow', '&File')) self.file_import_menu.setTitle(translate('OpenLP.MainWindow', '&Import')) self.file_export_menu.setTitle(translate('OpenLP.MainWindow', '&Export')) @@ -1150,9 +1150,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties): :param file_name: The file name of the service file. """ if modified: - title = '{title} - {name}*'.format(title=UiStrings().OLP, name=file_name) + title = '{title} - {name}*'.format(title=UiStrings().OpenLP, name=file_name) else: - title = '{title} - {name}'.format(title=UiStrings().OLP, name=file_name) + title = '{title} - {name}'.format(title=UiStrings().OpenLP, name=file_name) self.setWindowTitle(title) def show_status_message(self, message): diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index f3808dc31..1dfe0a7c3 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -105,7 +105,7 @@ class AlertsTab(SettingsTab): self.timeout_label.setText(translate('AlertsPlugin.AlertsTab', 'Alert timeout:')) self.timeout_spin_box.setSuffix(' {unit}'.format(unit=UiStrings().Seconds)) self.preview_group_box.setTitle(UiStrings().Preview) - self.font_preview.setText(UiStrings().OLPV2x) + self.font_preview.setText(UiStrings().OpenLP) def on_background_color_changed(self, color): """ diff --git a/openlp/plugins/remotes/lib/httprouter.py b/openlp/plugins/remotes/lib/httprouter.py index b3b45b03f..0b14d1685 100644 --- a/openlp/plugins/remotes/lib/httprouter.py +++ b/openlp/plugins/remotes/lib/httprouter.py @@ -277,7 +277,7 @@ class HttpRouter(RegistryProperties): Create a needs authorisation http header. """ self.send_response(401) - header = 'Basic realm=\"{}\"'.format(UiStrings().OLPV2) + header = 'Basic realm=\"{}\"'.format(UiStrings().OpenLP) self.send_header('WWW-Authenticate', header) self.send_header('Content-type', 'text/html') self.set_cache_headers() @@ -322,10 +322,10 @@ class HttpRouter(RegistryProperties): chords = translate('RemotePlugin.Mobile', 'Chords View') live = translate('RemotePlugin.Mobile', 'Live View') self.template_vars = { - 'app_title': "{main} {remote}".format(main=UiStrings().OLPV2x, remote=remote), - 'stage_title': "{main} {stage}".format(main=UiStrings().OLPV2x, stage=stage), - 'chords_title': "{main} {chords}".format(main=UiStrings().OLPV2x, chords=chords), - 'live_title': "{main} {live}".format(main=UiStrings().OLPV2x, live=live), + 'app_title': "{main} {remote}".format(main=UiStrings().OpenLP, remote=remote), + 'stage_title': "{main} {stage}".format(main=UiStrings().OpenLP, stage=stage), + 'chords_title': "{main} {chords}".format(main=UiStrings().OpenLP, chords=chords), + 'live_title': "{main} {live}".format(main=UiStrings().OpenLP, live=live), 'service_manager': translate('RemotePlugin.Mobile', 'Service Manager'), 'slide_controller': translate('RemotePlugin.Mobile', 'Slide Controller'), 'alerts': translate('RemotePlugin.Mobile', 'Alerts'), diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 3d4d059da..9f925b35c 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -206,7 +206,7 @@ class SongFormat(object): }, OpenLP2: { 'class': OpenLPSongImport, - 'name': UiStrings().OLPV2, + 'name': UiStrings().OpenLPv2AndUp, 'prefix': 'openLP2', 'selectMode': SongFormatSelect.SingleFile, 'filter': '{text} (*.sqlite)'.format(text=translate('SongsPlugin.ImportWizardForm', 'OpenLP 2 Databases')) diff --git a/tests/functional/openlp_core/test_init.py b/tests/functional/openlp_core/test_init.py index e18d0f376..de96c3f2a 100644 --- a/tests/functional/openlp_core/test_init.py +++ b/tests/functional/openlp_core/test_init.py @@ -23,7 +23,7 @@ import sys from unittest import TestCase, skip from unittest.mock import MagicMock, patch -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core import OpenLP, parse_options @@ -132,11 +132,11 @@ class TestInitFunctions(TestCase): self.assertEquals(args.rargs, 'dummy_temp', 'The service file should not be blank') -@skip('Figure out why this is causing a segfault') class TestOpenLP(TestCase): """ Test the OpenLP app class """ + @skip('Figure out why this is causing a segfault') @patch('openlp.core.QtWidgets.QApplication.exec') def test_exec(self, mocked_exec): """ @@ -225,3 +225,49 @@ class TestOpenLP(TestCase): MockedStandardButtons.assert_called_once_with(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0) assert result is True + + def test_process_events(self): + """ + Test that the app.process_events() method simply calls the Qt method + """ + # GIVEN: An app + app = OpenLP([]) + + # WHEN: process_events() is called + with patch.object(app, 'processEvents') as mocked_processEvents: + app.process_events() + + # THEN: processEvents was called + mocked_processEvents.assert_called_once_with() + + def test_set_busy_cursor(self): + """ + Test that the set_busy_cursor() method sets the cursor + """ + # GIVEN: An app + app = OpenLP([]) + + # WHEN: set_busy_cursor() is called + with patch.object(app, 'setOverrideCursor') as mocked_setOverrideCursor, \ + patch.object(app, 'processEvents') as mocked_processEvents: + app.set_busy_cursor() + + # THEN: The cursor should have been set + mocked_setOverrideCursor.assert_called_once_with(QtCore.Qt.BusyCursor) + mocked_processEvents.assert_called_once_with() + + def test_set_normal_cursor(self): + """ + Test that the set_normal_cursor() method resets the cursor + """ + # GIVEN: An app + app = OpenLP([]) + + # WHEN: set_normal_cursor() is called + with patch.object(app, 'restoreOverrideCursor') as mocked_restoreOverrideCursor, \ + patch.object(app, 'processEvents') as mocked_processEvents: + app.set_normal_cursor() + + # THEN: The cursor should have been set + mocked_restoreOverrideCursor.assert_called_once_with() + mocked_processEvents.assert_called_once_with() diff --git a/tests/functional/openlp_core_ui/test_mainwindow.py b/tests/functional/openlp_core_ui/test_mainwindow.py index e5f9dd745..be4427bb4 100644 --- a/tests/functional/openlp_core_ui/test_mainwindow.py +++ b/tests/functional/openlp_core_ui/test_mainwindow.py @@ -109,9 +109,9 @@ class TestMainWindow(TestCase, TestMixin): # WHEN no changes are made to the service - # THEN the main window's title shoud be the same as the OLP string in the UiStrings class - self.assertEqual(self.main_window.windowTitle(), UiStrings().OLP, - 'The main window\'s title should be the same as the OLP string in UiStrings class') + # THEN the main window's title shoud be the same as the OpenLP string in the UiStrings class + self.assertEqual(self.main_window.windowTitle(), UiStrings().OpenLP, + 'The main window\'s title should be the same as the OpenLP string in UiStrings class') def test_set_service_modifed(self): """ @@ -123,8 +123,8 @@ class TestMainWindow(TestCase, TestMixin): self.main_window.set_service_modified(True, 'test.osz') # THEN the main window's title should be set to the - self.assertEqual(self.main_window.windowTitle(), '%s - %s*' % (UiStrings().OLP, 'test.osz'), - 'The main window\'s title should be set to " - test.osz*"') + self.assertEqual(self.main_window.windowTitle(), '%s - %s*' % (UiStrings().OpenLP, 'test.osz'), + 'The main window\'s title should be set to " - test.osz*"') def test_set_service_unmodified(self): """ @@ -136,8 +136,8 @@ class TestMainWindow(TestCase, TestMixin): self.main_window.set_service_modified(False, 'test.osz') # THEN the main window's title should be set to the - self.assertEqual(self.main_window.windowTitle(), '%s - %s' % (UiStrings().OLP, 'test.osz'), - 'The main window\'s title should be set to " - test.osz"') + self.assertEqual(self.main_window.windowTitle(), '%s - %s' % (UiStrings().OpenLP, 'test.osz'), + 'The main window\'s title should be set to " - test.osz"') def test_mainwindow_configuration(self): """