From ede9bb70d93984927dd2c88e772fb26358403ec4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 5 Feb 2013 18:36:43 +0100 Subject: [PATCH 01/31] attempt to fix bug #1100277 Fixes: https://launchpad.net/bugs/1100277 --- openlp/core/lib/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index c34c824db..ca8a46126 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -373,16 +373,15 @@ def create_separated_list(stringlist): elif len(stringlist) == 1: return stringlist[0] elif len(stringlist) == 2: - return translate('OpenLP.core.lib', '%1 and %2', + return translate('OpenLP.core.lib', '%s and %s', 'Locale list separator: 2 items') % (stringlist[0], stringlist[1]) else: - merged = translate('OpenLP.core.lib', '%1, and %2', + merged = translate('OpenLP.core.lib', '%s, and %s', u'Locale list separator: end') % (stringlist[-2], stringlist[-1]) for index in reversed(range(1, len(stringlist) - 2)): - merged = translate('OpenLP.core.lib', '%1, %2', - u'Locale list separator: middle') % (stringlist[index], merged) - return translate('OpenLP.core.lib', '%1, %2', - u'Locale list separator: start') % (stringlist[0], merged) + merged = translate('OpenLP.core.lib', '%s, %s', + u'Locale list separator: middle') % (stringlist[index], merged) + return translate('OpenLP.core.lib', '%s, %s', u'Locale list separator: start') % (stringlist[0], merged) from registry import Registry From 6e17ff9d9e4d4e1239dd48e06434b5ce1ffd6b29 Mon Sep 17 00:00:00 2001 From: phill-ridout Date: Tue, 5 Feb 2013 19:57:08 +0000 Subject: [PATCH 02/31] Set lineEdit focus when displaying form --- openlp/core/ui/filerenameform.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index 0743578a1..ccdca9928 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -56,4 +56,5 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog): self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Copy')) else: self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Rename')) + self.fileNameEdit.setFocus() return QtGui.QDialog.exec_(self) From 022f0e0184b7f689ba598e1deb90dea203dc1d1f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Feb 2013 18:36:36 +0100 Subject: [PATCH 03/31] started with tests --- tests/functional/openlp_core_lib/test_lib.py | 98 +++++++++++++++++++- 1 file changed, 93 insertions(+), 5 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 176197e24..8c1f87852 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -7,7 +7,7 @@ from datetime import datetime, timedelta from mock import MagicMock, patch from openlp.core.lib import str_to_bool, translate, check_directory_exists, get_text_file_string, build_icon, \ - image_to_byte, check_item_selected, validate_thumb + image_to_byte, check_item_selected, validate_thumb, create_separated_list class TestLib(TestCase): @@ -308,14 +308,14 @@ class TestLib(TestCase): file_path = u'path/to/file' thumb_path = u'path/to/thumb' mocked_os.path.exists.return_value = False - + # WHEN: we run the validate_thumb() function result = validate_thumb(file_path, thumb_path) - + # THEN: we should have called a few functions, and the result should be False mocked_os.path.exists.assert_called_with(thumb_path) assert result is False, u'The result should be False' - + def validate_thumb_file_exists_and_newer_test(self): """ Test the validate_thumb() function when the thumbnail exists and has a newer timestamp than the file @@ -350,7 +350,7 @@ class TestLib(TestCase): thumb_mocked_stat.st_mtime = datetime.now() - timedelta(seconds=10) mocked_os.path.exists.return_value = True mocked_os.stat.side_effect = lambda fname: file_mocked_stat if fname == file_path else thumb_mocked_stat - + # WHEN: we run the validate_thumb() function result = validate_thumb(file_path, thumb_path) @@ -359,3 +359,91 @@ class TestLib(TestCase): mocked_os.stat.assert_any_call(file_path) mocked_os.stat.assert_any_call(thumb_path) assert result is False, u'The result should be False' + + def create_separated_list_qlocate_test(self): + """ + """ + with patch(u'openlp.core.lib.Qt.PYQT_VERSION_STR') as pyqt_version, \ + patch(u'openlp.core.lib.Qt.qVersion') as qt_version: + pyqt_version.return_value = u'4.9' + qt_version.return_value = u'4.8' + # GIVEN: A list of strings. + string_list = [u'Author 1', u'Author 2', u'Author 3'] + + # WHEN: We get a string build from the entries it the list and a seperator. + string_result = create_separated_list(string_list) + + # THEN: + assert string_result == u'Author 1, Author 2, and Author 3', u'The string should be u\'Author 1, ' \ + 'Author 2, and Author 3\'.' + + def create_separated_list_empty_list_test(self): + """ + """ + with patch(u'openlp.core.lib.Qt.PYQT_VERSION_STR') as pyqt_version, \ + patch(u'openlp.core.lib.Qt.qVersion') as qt_version: + pyqt_version.return_value = u'3.0' + qt_version.return_value = u'3.0' + # GIVEN: A list of strings. + string_list = [] + + # WHEN: We get a string build from the entries it the list and a seperator. + string_result = create_separated_list(string_list) + + # THEN: + assert string_result == u'', u'The string sould be empty.' + + def create_separated_list_with_one_item_test(self): + """ + """ + with patch(u'openlp.core.lib.Qt.PYQT_VERSION_STR') as pyqt_version, \ + patch(u'openlp.core.lib.Qt.qVersion') as qt_version: + pyqt_version.return_value = u'3.0' + qt_version.return_value = u'3.0' + # GIVEN: A list of strings. + string_list = [u'Author 1'] + + # WHEN: We get a string build from the entries it the list and a seperator. + string_result = create_separated_list(string_list) + + # THEN: + assert string_result == u'Author 1', u'The string should be u\'Author 1\'.' + + def create_separated_list_with_two_items_test(self): + """ + """ + with patch(u'openlp.core.lib.Qt.PYQT_VERSION_STR') as pyqt_version, \ + patch(u'openlp.core.lib.Qt.qVersion') as qt_version, \ + patch(u'openlp.core.lib.translate') as mocked_translate: + pyqt_version.return_value = u'3.0' + qt_version.return_value = u'3.0' + mocked_translate.return_value = u'%s and %s' + # GIVEN: A list of strings. + string_list = [u'Author 1', u'Author 2'] + + # WHEN: We get a string build from the entries it the list and a seperator. + string_result = create_separated_list(string_list) + + # THEN: + assert string_result == u'Author 1 and Author 2', u'The string should be u\'Author 1 and Author 2\'.' + + def create_separated_list_with_three_items_test(self): + """ + """ + with patch(u'openlp.core.lib.Qt.PYQT_VERSION_STR') as pyqt_version, \ + patch(u'openlp.core.lib.Qt.qVersion') as qt_version, \ + patch(u'openlp.core.lib.translate') as mocked_translate: + # I need two translate functions returning two different things! + mocked_translate.return_value = u'' + pyqt_version.return_value = u'3.0' + qt_version.return_value = u'3.0' + # GIVEN: A list of strings. + string_list = [u'Author 1', u'Author 2', u'Author 3'] + + # WHEN: We get a string build from the entries it the list and a seperator. + string_result = create_separated_list(string_list) + + # THEN: + assert string_result == u'Author 1, Author 2 and Author 3', u'The string should be u\'Author 1, ' \ + 'Author 2 and Author 3\'.' + From 2c8f0e66b2887680e1128a52b92d728769f01e4e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Feb 2013 20:45:11 +0100 Subject: [PATCH 04/31] comleted tests --- tests/functional/openlp_core_lib/test_lib.py | 54 ++++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 8c1f87852..aa3291d78 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -363,16 +363,20 @@ class TestLib(TestCase): def create_separated_list_qlocate_test(self): """ """ - with patch(u'openlp.core.lib.Qt.PYQT_VERSION_STR') as pyqt_version, \ - patch(u'openlp.core.lib.Qt.qVersion') as qt_version: - pyqt_version.return_value = u'4.9' - qt_version.return_value = u'4.8' + with patch(u'openlp.core.lib.Qt') as mocked_QT, \ + patch(u'openlp.core.lib.QtCore.QLocale.createSeparatedList') as mocked_createSeparatedList: + mocked_QT.PYQT_VERSION_STR = u'4.9' + mocked_QT.qVersion.return_value = u'4.8' + mocked_createSeparatedList.return_value = u'Author 1, Author 2, and Author 3' + # GIVEN: A list of strings. string_list = [u'Author 1', u'Author 2', u'Author 3'] # WHEN: We get a string build from the entries it the list and a seperator. string_result = create_separated_list(string_list) + print string_result + # THEN: assert string_result == u'Author 1, Author 2, and Author 3', u'The string should be u\'Author 1, ' \ 'Author 2, and Author 3\'.' @@ -380,10 +384,10 @@ class TestLib(TestCase): def create_separated_list_empty_list_test(self): """ """ - with patch(u'openlp.core.lib.Qt.PYQT_VERSION_STR') as pyqt_version, \ - patch(u'openlp.core.lib.Qt.qVersion') as qt_version: - pyqt_version.return_value = u'3.0' - qt_version.return_value = u'3.0' + with patch(u'openlp.core.lib.Qt') as mocked_QT: + mocked_QT.PYQT_VERSION_STR = u'4.8' + mocked_QT.qVersion.return_value = u'4.7' + # GIVEN: A list of strings. string_list = [] @@ -396,10 +400,10 @@ class TestLib(TestCase): def create_separated_list_with_one_item_test(self): """ """ - with patch(u'openlp.core.lib.Qt.PYQT_VERSION_STR') as pyqt_version, \ - patch(u'openlp.core.lib.Qt.qVersion') as qt_version: - pyqt_version.return_value = u'3.0' - qt_version.return_value = u'3.0' + with patch(u'openlp.core.lib.Qt') as mocked_QT: + mocked_QT.PYQT_VERSION_STR = u'4.8' + mocked_QT.qVersion.return_value = u'4.7' + # GIVEN: A list of strings. string_list = [u'Author 1'] @@ -412,12 +416,11 @@ class TestLib(TestCase): def create_separated_list_with_two_items_test(self): """ """ - with patch(u'openlp.core.lib.Qt.PYQT_VERSION_STR') as pyqt_version, \ - patch(u'openlp.core.lib.Qt.qVersion') as qt_version, \ - patch(u'openlp.core.lib.translate') as mocked_translate: - pyqt_version.return_value = u'3.0' - qt_version.return_value = u'3.0' + with patch(u'openlp.core.lib.Qt') as mocked_QT, patch(u'openlp.core.lib.translate') as mocked_translate: + mocked_QT.PYQT_VERSION_STR = u'4.8' + mocked_QT.qVersion.return_value = u'4.7' mocked_translate.return_value = u'%s and %s' + # GIVEN: A list of strings. string_list = [u'Author 1', u'Author 2'] @@ -430,13 +433,11 @@ class TestLib(TestCase): def create_separated_list_with_three_items_test(self): """ """ - with patch(u'openlp.core.lib.Qt.PYQT_VERSION_STR') as pyqt_version, \ - patch(u'openlp.core.lib.Qt.qVersion') as qt_version, \ - patch(u'openlp.core.lib.translate') as mocked_translate: - # I need two translate functions returning two different things! - mocked_translate.return_value = u'' - pyqt_version.return_value = u'3.0' - qt_version.return_value = u'3.0' + with patch(u'openlp.core.lib.Qt') as mocked_QT, patch(u'openlp.core.lib.translate') as mocked_translate: + mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate + mocked_QT.PYQT_VERSION_STR = u'4.8' + mocked_QT.qVersion.return_value = u'4.7' + # GIVEN: A list of strings. string_list = [u'Author 1', u'Author 2', u'Author 3'] @@ -444,6 +445,5 @@ class TestLib(TestCase): string_result = create_separated_list(string_list) # THEN: - assert string_result == u'Author 1, Author 2 and Author 3', u'The string should be u\'Author 1, ' \ - 'Author 2 and Author 3\'.' - + assert string_result == u'Author 1, Author 2, and Author 3', u'The string should be u\'Author 1, ' \ + 'Author 2, and Author 3\'.' From 818bd4a4353553aedb036ecebee880031f66ff33 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Feb 2013 20:49:39 +0100 Subject: [PATCH 05/31] fixed version number compare --- openlp/core/lib/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index ca8a46126..d7b5ef8b5 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -30,6 +30,7 @@ The :mod:`lib` module contains most of the components and libraries that make OpenLP work. """ +from distutils.version import LooseVersion import logging import os @@ -366,7 +367,8 @@ def create_separated_list(stringlist): ``stringlist`` List of unicode strings """ - if Qt.PYQT_VERSION_STR >= u'4.9' and Qt.qVersion() >= u'4.8': + if LooseVersion(Qt.PYQT_VERSION_STR) >= LooseVersion(u'4.9') and \ + LooseVersion(Qt.qVersion()) >= LooseVersion(u'4.8'): return QtCore.QLocale().createSeparatedList(stringlist) if not stringlist: return u'' From fe74e66400695264febd743f791b588d58fe0ac0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Feb 2013 20:55:28 +0100 Subject: [PATCH 06/31] docs ;) --- tests/functional/openlp_core_lib/test_lib.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index aa3291d78..e78f78c0d 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -362,6 +362,7 @@ class TestLib(TestCase): def create_separated_list_qlocate_test(self): """ + Test the create_separated_list function using the Qt provided method. """ with patch(u'openlp.core.lib.Qt') as mocked_QT, \ patch(u'openlp.core.lib.QtCore.QLocale.createSeparatedList') as mocked_createSeparatedList: @@ -383,6 +384,7 @@ class TestLib(TestCase): def create_separated_list_empty_list_test(self): """ + Test the create_separated_list function with an empty list. """ with patch(u'openlp.core.lib.Qt') as mocked_QT: mocked_QT.PYQT_VERSION_STR = u'4.8' @@ -399,6 +401,7 @@ class TestLib(TestCase): def create_separated_list_with_one_item_test(self): """ + Test the create_separated_list function with a list consisting of only one entry. """ with patch(u'openlp.core.lib.Qt') as mocked_QT: mocked_QT.PYQT_VERSION_STR = u'4.8' @@ -415,6 +418,7 @@ class TestLib(TestCase): def create_separated_list_with_two_items_test(self): """ + Test the create_separated_list function with a list of two entries. """ with patch(u'openlp.core.lib.Qt') as mocked_QT, patch(u'openlp.core.lib.translate') as mocked_translate: mocked_QT.PYQT_VERSION_STR = u'4.8' @@ -432,6 +436,7 @@ class TestLib(TestCase): def create_separated_list_with_three_items_test(self): """ + Test the create_separated_list function with a list of three items. """ with patch(u'openlp.core.lib.Qt') as mocked_QT, patch(u'openlp.core.lib.translate') as mocked_translate: mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate From 4c2bc4667375e06f4feefadd9b66d5e5cd90afcc Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Feb 2013 21:36:59 +0100 Subject: [PATCH 07/31] added nose to checkdependencies script --- scripts/check_dependencies.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index be15414b4..4b56acb63 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -40,6 +40,12 @@ import os import sys from distutils.version import LooseVersion +# If we import uno before nose this will greate a warning. Just try to import nose first to supress the warning. +try: + import nose +except ImportError: + pass + is_win = sys.platform.startswith('win') VERS = { @@ -85,6 +91,7 @@ OPTIONAL_MODULES = [ ('MySQLdb', ' (MySQL support)'), ('psycopg2', ' (PostgreSQL support)'), ('pytest', ' (testing framework)'), + ('nose', ' (testing framework)'), ] w = sys.stdout.write From 1fc779e8ed3faf8cdc390fb0e42eb1c2c39e0e08 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Feb 2013 21:37:30 +0100 Subject: [PATCH 08/31] use CAPS --- scripts/check_dependencies.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index 4b56acb63..2035d1bb0 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -46,7 +46,7 @@ try: except ImportError: pass -is_win = sys.platform.startswith('win') +IS_WIN = sys.platform.startswith('win') VERS = { 'Python': '2.6', @@ -54,7 +54,7 @@ VERS = { 'Qt4': '4.6', 'sqlalchemy': '0.5', # pyenchant 1.6 required on Windows - 'enchant': '1.6' if is_win else '1.3' + 'enchant': '1.6' if IS_WIN else '1.3' } # pywin32 @@ -183,7 +183,7 @@ def main(): for m in OPTIONAL_MODULES: check_module(m[0], text=m[1]) - if is_win: + if IS_WIN: print('Checking for Windows specific modules...') for m in WIN32_MODULES: check_module(m) From 47fa8209ba9c5e9d47cc124e95e811f7188070c7 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Feb 2013 21:42:09 +0100 Subject: [PATCH 09/31] changed wording --- scripts/check_dependencies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index 2035d1bb0..52b832c48 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -40,7 +40,7 @@ import os import sys from distutils.version import LooseVersion -# If we import uno before nose this will greate a warning. Just try to import nose first to supress the warning. +# If we try to import uno before nose this will greate a warning. Just try to import nose first to supress the warning. try: import nose except ImportError: From ed38ba35192763c36728a2eb01ea613516b52254 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Feb 2013 21:47:57 +0100 Subject: [PATCH 10/31] fixed comments --- tests/functional/openlp_core_lib/test_lib.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index e78f78c0d..b05eb8da6 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -378,7 +378,7 @@ class TestLib(TestCase): print string_result - # THEN: + # THEN: We should have "Author 1, Author 2, and Author 3" assert string_result == u'Author 1, Author 2, and Author 3', u'The string should be u\'Author 1, ' \ 'Author 2, and Author 3\'.' @@ -396,7 +396,7 @@ class TestLib(TestCase): # WHEN: We get a string build from the entries it the list and a seperator. string_result = create_separated_list(string_list) - # THEN: + # THEN: We shoud have an emptry string. assert string_result == u'', u'The string sould be empty.' def create_separated_list_with_one_item_test(self): @@ -413,7 +413,7 @@ class TestLib(TestCase): # WHEN: We get a string build from the entries it the list and a seperator. string_result = create_separated_list(string_list) - # THEN: + # THEN: We should have "Author 1" assert string_result == u'Author 1', u'The string should be u\'Author 1\'.' def create_separated_list_with_two_items_test(self): @@ -431,7 +431,7 @@ class TestLib(TestCase): # WHEN: We get a string build from the entries it the list and a seperator. string_result = create_separated_list(string_list) - # THEN: + # THEN: We should have "Author 1 and Author 2" assert string_result == u'Author 1 and Author 2', u'The string should be u\'Author 1 and Author 2\'.' def create_separated_list_with_three_items_test(self): @@ -449,6 +449,6 @@ class TestLib(TestCase): # WHEN: We get a string build from the entries it the list and a seperator. string_result = create_separated_list(string_list) - # THEN: + # THEN: We should have "Author 1, Author 2, and Author 3" assert string_result == u'Author 1, Author 2, and Author 3', u'The string should be u\'Author 1, ' \ 'Author 2, and Author 3\'.' From 396d0b1cd20a0e79017a44b00d458d0747f36d9b Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Feb 2013 22:39:52 +0100 Subject: [PATCH 11/31] remove pytest and renamed mocked function --- scripts/check_dependencies.py | 1 - tests/functional/openlp_core_lib/test_lib.py | 30 ++++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index 52b832c48..3485b8505 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -90,7 +90,6 @@ OPTIONAL_MODULES = [ ('sqlite', ' (SQLite 2 support)'), ('MySQLdb', ' (MySQL support)'), ('psycopg2', ' (PostgreSQL support)'), - ('pytest', ' (testing framework)'), ('nose', ' (testing framework)'), ] diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index b05eb8da6..6035085e4 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -364,10 +364,10 @@ class TestLib(TestCase): """ Test the create_separated_list function using the Qt provided method. """ - with patch(u'openlp.core.lib.Qt') as mocked_QT, \ + with patch(u'openlp.core.lib.Qt') as mocked_qt, \ patch(u'openlp.core.lib.QtCore.QLocale.createSeparatedList') as mocked_createSeparatedList: - mocked_QT.PYQT_VERSION_STR = u'4.9' - mocked_QT.qVersion.return_value = u'4.8' + mocked_qt.PYQT_VERSION_STR = u'4.9' + mocked_qt.qVersion.return_value = u'4.8' mocked_createSeparatedList.return_value = u'Author 1, Author 2, and Author 3' # GIVEN: A list of strings. @@ -386,9 +386,9 @@ class TestLib(TestCase): """ Test the create_separated_list function with an empty list. """ - with patch(u'openlp.core.lib.Qt') as mocked_QT: - mocked_QT.PYQT_VERSION_STR = u'4.8' - mocked_QT.qVersion.return_value = u'4.7' + with patch(u'openlp.core.lib.Qt') as mocked_qt: + mocked_qt.PYQT_VERSION_STR = u'4.8' + mocked_qt.qVersion.return_value = u'4.7' # GIVEN: A list of strings. string_list = [] @@ -403,9 +403,9 @@ class TestLib(TestCase): """ Test the create_separated_list function with a list consisting of only one entry. """ - with patch(u'openlp.core.lib.Qt') as mocked_QT: - mocked_QT.PYQT_VERSION_STR = u'4.8' - mocked_QT.qVersion.return_value = u'4.7' + with patch(u'openlp.core.lib.Qt') as mocked_qt: + mocked_qt.PYQT_VERSION_STR = u'4.8' + mocked_qt.qVersion.return_value = u'4.7' # GIVEN: A list of strings. string_list = [u'Author 1'] @@ -420,9 +420,9 @@ class TestLib(TestCase): """ Test the create_separated_list function with a list of two entries. """ - with patch(u'openlp.core.lib.Qt') as mocked_QT, patch(u'openlp.core.lib.translate') as mocked_translate: - mocked_QT.PYQT_VERSION_STR = u'4.8' - mocked_QT.qVersion.return_value = u'4.7' + with patch(u'openlp.core.lib.Qt') as mocked_qt, patch(u'openlp.core.lib.translate') as mocked_translate: + mocked_qt.PYQT_VERSION_STR = u'4.8' + mocked_qt.qVersion.return_value = u'4.7' mocked_translate.return_value = u'%s and %s' # GIVEN: A list of strings. @@ -438,10 +438,10 @@ class TestLib(TestCase): """ Test the create_separated_list function with a list of three items. """ - with patch(u'openlp.core.lib.Qt') as mocked_QT, patch(u'openlp.core.lib.translate') as mocked_translate: + with patch(u'openlp.core.lib.Qt') as mocked_qt, patch(u'openlp.core.lib.translate') as mocked_translate: mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate - mocked_QT.PYQT_VERSION_STR = u'4.8' - mocked_QT.qVersion.return_value = u'4.7' + mocked_qt.PYQT_VERSION_STR = u'4.8' + mocked_qt.qVersion.return_value = u'4.7' # GIVEN: A list of strings. string_list = [u'Author 1', u'Author 2', u'Author 3'] From 947cfce93184e9d748c8f456fc2588f6a166bf83 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Feb 2013 22:50:55 +0100 Subject: [PATCH 12/31] cough... --- tests/functional/openlp_core_lib/test_lib.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 6035085e4..568051980 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -376,8 +376,6 @@ class TestLib(TestCase): # WHEN: We get a string build from the entries it the list and a seperator. string_result = create_separated_list(string_list) - print string_result - # THEN: We should have "Author 1, Author 2, and Author 3" assert string_result == u'Author 1, Author 2, and Author 3', u'The string should be u\'Author 1, ' \ 'Author 2, and Author 3\'.' From 589d335d3941a6b3b43c6e68a482cc8c055a112c Mon Sep 17 00:00:00 2001 From: phill-ridout Date: Thu, 7 Feb 2013 21:55:22 +0000 Subject: [PATCH 13/31] Changed filerenamefor to registry. Started on test for filerenameform --- openlp/core/ui/filerenameform.py | 16 +++++++++++++--- openlp/core/ui/thememanager.py | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index ccdca9928..934a8dee8 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -34,18 +34,18 @@ from PyQt4 import QtGui from filerenamedialog import Ui_FileRenameDialog -from openlp.core.lib import translate +from openlp.core.lib import translate, Registry class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog): """ The file rename dialog """ - def __init__(self, parent): + def __init__(self): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + QtGui.QDialog.__init__(self, self.main_window) self.setupUi(self) def exec_(self, copy=False): @@ -58,3 +58,13 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog): self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Rename')) self.fileNameEdit.setFocus() return QtGui.QDialog.exec_(self) + + def _get_main_window(self): + """ + Adds the main window to the class dynamically + """ + if not hasattr(self, u'_main_window'): + self._main_window = Registry().get(u'main_window') + return self._main_window + + main_window = property(_get_main_window) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a482a3c44..666f80dbe 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -62,7 +62,7 @@ class ThemeManager(QtGui.QWidget): Registry().register(u'theme_manager', self) self.settingsSection = u'themes' self.themeForm = ThemeForm(self) - self.fileRenameForm = FileRenameForm(self) + self.fileRenameForm = FileRenameForm() # start with the layout self.layout = QtGui.QVBoxLayout(self) self.layout.setSpacing(0) From e1552ddce19c23acd957de4aa58042e869041526 Mon Sep 17 00:00:00 2001 From: phill-ridout Date: Fri, 8 Feb 2013 19:13:18 +0000 Subject: [PATCH 14/31] actually added test file --- .../openlp_core_ui/test_filerenamedialog.py | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/interfaces/openlp_core_ui/test_filerenamedialog.py diff --git a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py new file mode 100644 index 000000000..cc4f2b1c5 --- /dev/null +++ b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py @@ -0,0 +1,83 @@ +""" + Package to test the openlp.core.ui package. +""" +from unittest import TestCase + +from mock import patch +from openlp.core.lib import Registry +from openlp.core.ui import filerenameform +from PyQt4 import QtCore, QtGui, QtTest + +class TestStartFileRenameForm(TestCase): + + def setUp(self): + """ + Create the UI + """ + registry = Registry.create() + self.app = QtGui.QApplication([]) + self.main_window = QtGui.QMainWindow() + Registry().register(u'main_window', self.main_window) + self.form = filerenameform.FileRenameForm() + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.form + del self.main_window + del self.app + + def basic_display_test(self): + """ + Test FileRenameForm functionality + """ + # GIVEN: FileRenameForm with no ARGS + + # WHEN displaying the UI + with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + self.form.exec_() + + # THEN the window title is set as + self.assertEqual(self.form.windowTitle(), u'File Rename', u'The window title should be "File Rename"') + + # GIVEN: FileRenameForm with False ARG + false_arg = False + + # WHEN displaying the UI + with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + self.form.exec_(false_arg) + + # THEN the window title is set as + self.assertEqual(self.form.windowTitle(), u'File Rename', u'The window title should be "File Rename"') + + # GIVEN: FileRenameForm with False ARG + true_arg = True + + # WHEN displaying the UI and pressing enter + with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + self.form.exec_(true_arg) + + # THEN the window title is set as + self.assertEqual(self.form.windowTitle(), u'File Copy', u'The window title should be "File Copy"') + + # GIVEN: FileRenameForm with defaults + + # WHEN displaying the UI + with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + self.form.exec_() + + # THEN the lineEdit should have focus + self.assertEqual(self.form.fileNameEdit.hasFocus(), True, u'fileNameEdit should have focus.') + + + + # Regression test for bug1067251 + # GIVEN: FileRenameForm with defaults + + # WHEN displaying the UI + # with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + # self.form.exec_() + + # THEN the lineEdit should have focus + #self.assertEqual(self.form.fileNameEdit.hasFocus(), u'File Rename', u'The window title should be "File Rename"') \ No newline at end of file From 7d7da00848bedb375f2557b611b0e2fc00079b4f Mon Sep 17 00:00:00 2001 From: phill-ridout Date: Fri, 8 Feb 2013 21:49:26 +0000 Subject: [PATCH 15/31] made changes according to Superfly's instructions. --- tests/interfaces/openlp_core_ui/test_filerenamedialog.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py index cc4f2b1c5..0f5cfb9cf 100644 --- a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py +++ b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py @@ -35,7 +35,7 @@ class TestStartFileRenameForm(TestCase): # GIVEN: FileRenameForm with no ARGS # WHEN displaying the UI - with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: self.form.exec_() # THEN the window title is set as @@ -45,7 +45,7 @@ class TestStartFileRenameForm(TestCase): false_arg = False # WHEN displaying the UI - with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: self.form.exec_(false_arg) # THEN the window title is set as @@ -55,7 +55,7 @@ class TestStartFileRenameForm(TestCase): true_arg = True # WHEN displaying the UI and pressing enter - with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: self.form.exec_(true_arg) # THEN the window title is set as @@ -64,7 +64,7 @@ class TestStartFileRenameForm(TestCase): # GIVEN: FileRenameForm with defaults # WHEN displaying the UI - with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: self.form.exec_() # THEN the lineEdit should have focus From 7f3c18f0a04e2c55b8b8f87f215034b7ecbe5464 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 9 Feb 2013 16:20:29 +0100 Subject: [PATCH 16/31] fixed regression --- openlp/plugins/alerts/lib/alertsmanager.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index ab0f7c1d9..42a28eee1 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -35,7 +35,7 @@ import logging from PyQt4 import QtCore -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Receiver, translate, Registry log = logging.getLogger(__name__) @@ -87,7 +87,7 @@ class AlertsManager(QtCore.QObject): return text = self.alertList.pop(0) alertTab = self.parent().settingsTab - self.parent().liveController.display.alert(text, alertTab.location) + self.live_controller.display.alert(text, alertTab.location) # Check to see if we have a timer running. if self.timer_id == 0: self.timer_id = self.startTimer(int(alertTab.timeout) * 1000) @@ -103,7 +103,18 @@ class AlertsManager(QtCore.QObject): log.debug(u'timer event') if event.timerId() == self.timer_id: alertTab = self.parent().settingsTab - self.parent().liveController.display.alert(u'', alertTab.location) + self.live_controller.display.alert(u'', alertTab.location) self.killTimer(self.timer_id) self.timer_id = 0 self.generateAlert() + + + def _get_live_controller(self): + """ + Adds the live controller to the class dynamically + """ + if not hasattr(self, u'_live_controller'): + self._live_controller = Registry().get(u'live_controller') + return self._live_controller + + live_controller = property(_get_live_controller) From 17200d85fc94f51f2accf73aa69ea94f14989c87 Mon Sep 17 00:00:00 2001 From: phill-ridout Date: Sat, 9 Feb 2013 21:23:43 +0000 Subject: [PATCH 17/31] some more changes to the test --- .../openlp_core_ui/test_filerenamedialog.py | 66 ++++++++----------- 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py index 0f5cfb9cf..9e242f0d5 100644 --- a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py +++ b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py @@ -28,56 +28,42 @@ class TestStartFileRenameForm(TestCase): del self.main_window del self.app - def basic_display_test(self): + def window_title_test(self): """ - Test FileRenameForm functionality + Test the windowTitle of the FileRenameDialog """ - # GIVEN: FileRenameForm with no ARGS - - # WHEN displaying the UI + # GIVEN: A mocked QDialog.exec_() method with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: + + # WHEN: The form is executed with no args self.form.exec_() - # THEN the window title is set as - self.assertEqual(self.form.windowTitle(), u'File Rename', u'The window title should be "File Rename"') + # THEN: the window title is set correctly + self.assertEqual(self.form.windowTitle(), u'File Rename', u'The window title should be "File Rename"') - # GIVEN: FileRenameForm with False ARG - false_arg = False + # WHEN: The form is executed with False arg + self.form.exec_(False) - # WHEN displaying the UI - with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: - self.form.exec_(false_arg) + # THEN: the window title is set correctly + self.assertEqual(self.form.windowTitle(), u'File Rename', u'The window title should be "File Rename"') - # THEN the window title is set as - self.assertEqual(self.form.windowTitle(), u'File Rename', u'The window title should be "File Rename"') + # WHEN: The form is executed with True arg + self.form.exec_(True) - # GIVEN: FileRenameForm with False ARG - true_arg = True + # THEN: the window title is set correctly + self.assertEqual(self.form.windowTitle(), u'File Copy', u'The window title should be "File Copy"') - # WHEN displaying the UI and pressing enter - with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: - self.form.exec_(true_arg) + def line_edit_focus_test(self): + """ + Regression test for bug1067251 + Test that the fileNameEdit setFocus has called with True when executed + """ + # GIVEN: A mocked QLineEdit class + with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec, \ + patch(u'PyQt4.QtGui.QLineEdit') as mocked_line_edit: - # THEN the window title is set as - self.assertEqual(self.form.windowTitle(), u'File Copy', u'The window title should be "File Copy"') - - # GIVEN: FileRenameForm with defaults - - # WHEN displaying the UI - with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: + # WHEN: The form is executed with no args self.form.exec_() - # THEN the lineEdit should have focus - self.assertEqual(self.form.fileNameEdit.hasFocus(), True, u'fileNameEdit should have focus.') - - - - # Regression test for bug1067251 - # GIVEN: FileRenameForm with defaults - - # WHEN displaying the UI - # with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: - # self.form.exec_() - - # THEN the lineEdit should have focus - #self.assertEqual(self.form.fileNameEdit.hasFocus(), u'File Rename', u'The window title should be "File Rename"') \ No newline at end of file + # THEN: the setFocus method of the fileNameEdit has been called with True + mocked_line_edit.setFocus.assert_called_with() From d0104bf7954b89238544dcf6c96e31b7691d88e6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 10 Feb 2013 19:59:00 +0100 Subject: [PATCH 18/31] fixed comments --- tests/functional/openlp_core_lib/test_lib.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 568051980..8527373dc 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -366,11 +366,10 @@ class TestLib(TestCase): """ with patch(u'openlp.core.lib.Qt') as mocked_qt, \ patch(u'openlp.core.lib.QtCore.QLocale.createSeparatedList') as mocked_createSeparatedList: + # GIVEN: A list of strings and the mocked Qt module. mocked_qt.PYQT_VERSION_STR = u'4.9' mocked_qt.qVersion.return_value = u'4.8' mocked_createSeparatedList.return_value = u'Author 1, Author 2, and Author 3' - - # GIVEN: A list of strings. string_list = [u'Author 1', u'Author 2', u'Author 3'] # WHEN: We get a string build from the entries it the list and a seperator. @@ -385,10 +384,9 @@ class TestLib(TestCase): Test the create_separated_list function with an empty list. """ with patch(u'openlp.core.lib.Qt') as mocked_qt: + # GIVEN: An empty list and the mocked Qt module. mocked_qt.PYQT_VERSION_STR = u'4.8' mocked_qt.qVersion.return_value = u'4.7' - - # GIVEN: A list of strings. string_list = [] # WHEN: We get a string build from the entries it the list and a seperator. @@ -402,10 +400,9 @@ class TestLib(TestCase): Test the create_separated_list function with a list consisting of only one entry. """ with patch(u'openlp.core.lib.Qt') as mocked_qt: + # GIVEN: A list with a string and the mocked Qt module. mocked_qt.PYQT_VERSION_STR = u'4.8' mocked_qt.qVersion.return_value = u'4.7' - - # GIVEN: A list of strings. string_list = [u'Author 1'] # WHEN: We get a string build from the entries it the list and a seperator. @@ -419,11 +416,10 @@ class TestLib(TestCase): Test the create_separated_list function with a list of two entries. """ with patch(u'openlp.core.lib.Qt') as mocked_qt, patch(u'openlp.core.lib.translate') as mocked_translate: + # GIVEN: A list of strings and the mocked Qt module. mocked_qt.PYQT_VERSION_STR = u'4.8' mocked_qt.qVersion.return_value = u'4.7' mocked_translate.return_value = u'%s and %s' - - # GIVEN: A list of strings. string_list = [u'Author 1', u'Author 2'] # WHEN: We get a string build from the entries it the list and a seperator. @@ -437,11 +433,11 @@ class TestLib(TestCase): Test the create_separated_list function with a list of three items. """ with patch(u'openlp.core.lib.Qt') as mocked_qt, patch(u'openlp.core.lib.translate') as mocked_translate: - mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate + # GIVEN: A list with a string and the mocked Qt module. mocked_qt.PYQT_VERSION_STR = u'4.8' mocked_qt.qVersion.return_value = u'4.7' - - # GIVEN: A list of strings. + # Always return the untranslated string. + mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate string_list = [u'Author 1', u'Author 2', u'Author 3'] # WHEN: We get a string build from the entries it the list and a seperator. From 75b8ed55fa130fbc317ca597fd02d38153cce957 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 11 Feb 2013 09:31:46 +0100 Subject: [PATCH 19/31] fixed bug 1047995 by reimplementing the keyPressEvent Fixes: https://launchpad.net/bugs/1047995 --- openlp/plugins/songs/forms/editsongform.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 46ea0029c..87f948aa0 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -116,6 +116,23 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.findVerseSplit = re.compile(u'---\[\]---\n', re.UNICODE) self.whitespace = re.compile(r'\W+', re.UNICODE) + def keyPressEvent(self, event): + """ + Reimplement the keyPressEvent to react on Return/Enter keys. When some combo boxes have focus we do not want + dialog's default action be triggered but instead our own. + + ``event`` + A QtGui.QKeyEvent event. + """ + if event.key() in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return): + if self.authorsComboBox.hasFocus() and self.authorsComboBox.currentText(): + self.onAuthorAddButtonClicked() + return + if self.topicsComboBox.hasFocus() and self.topicsComboBox.currentText(): + self.onTopicAddButtonClicked() + return + QtGui.QDialog.keyPressEvent(self, event) + def initialise(self): """ Set up the form for when it is displayed. From 35eebb2a8eec6dd6f0807b1e793b528c7da334e2 Mon Sep 17 00:00:00 2001 From: phill-ridout Date: Mon, 11 Feb 2013 20:47:53 +0000 Subject: [PATCH 20/31] Added validator test --- .../openlp_core_ui/test_filerenamedialog.py | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py index 9e242f0d5..3e22b11e1 100644 --- a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py +++ b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py @@ -3,10 +3,10 @@ """ from unittest import TestCase -from mock import patch +from mock import MagicMock, patch from openlp.core.lib import Registry from openlp.core.ui import filerenameform -from PyQt4 import QtCore, QtGui, QtTest +from PyQt4 import QtGui, QtTest class TestStartFileRenameForm(TestCase): @@ -58,12 +58,26 @@ class TestStartFileRenameForm(TestCase): Regression test for bug1067251 Test that the fileNameEdit setFocus has called with True when executed """ - # GIVEN: A mocked QLineEdit class - with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec, \ - patch(u'PyQt4.QtGui.QLineEdit') as mocked_line_edit: + # GIVEN: A mocked QDialog.exec_() method and mocked fileNameEdit.setFocus() method. + with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: + mocked_set_focus = MagicMock() + self.form.fileNameEdit.setFocus = mocked_set_focus - # WHEN: The form is executed with no args + # WHEN: The form is executed self.form.exec_() # THEN: the setFocus method of the fileNameEdit has been called with True - mocked_line_edit.setFocus.assert_called_with() + mocked_set_focus.assert_called_with() + + def file_name_validation_test(self): + """ + Test the fileNameEdit validation + """ + # GIVEN: QLineEdit with a validator set with illegal file name characters. + + # WHEN: 'Typing' a string containing invalid file characters. + QtTest.QTest.keyClicks(self.form.fileNameEdit, u'I/n\\v?a*l|i \F[i\l]e" :N+a%me') + + # THEN: The text in the QLineEdit should be the same as the input string with the invalid chatacters filtered + # out. + self.assertEqual(self.form.fileNameEdit.text(), u'Invalid File Name') From 6efe1bf602b7b8c1cbc8685adbf8907bbc79c29e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 12 Feb 2013 08:49:01 +0100 Subject: [PATCH 21/31] image and remote plugin regression --- openlp/plugins/images/imageplugin.py | 14 ++++++- openlp/plugins/remotes/lib/httpserver.py | 53 ++++++++++++++++++------ 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 0f2829dbc..83c424e86 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui import logging -from openlp.core.lib import Plugin, StringContent, Receiver, ImageSource, Settings, build_icon, translate +from openlp.core.lib import Plugin, StringContent, Receiver, ImageSource, Settings, Registry, build_icon, translate from openlp.plugins.images.lib import ImageMediaItem, ImageTab log = logging.getLogger(__name__) @@ -98,4 +98,14 @@ class ImagePlugin(Plugin): last part of saving the config. """ background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color')) - self.liveController.imageManager.update_images_border(ImageSource.ImagePlugin, background) + self.image_manager.update_images_border(ImageSource.ImagePlugin, background) + + def _get_image_manager(self): + """ + Adds the image manager to the class dynamically + """ + if not hasattr(self, u'_image_manager'): + self._image_manager = Registry().get(u'image_manager') + return self._image_manager + + image_manager = property(_get_image_manager) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index d444fc1c4..127c2c13b 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -123,7 +123,7 @@ import urlparse from PyQt4 import QtCore, QtNetwork from mako.template import Template -from openlp.core.lib import Receiver, Settings, PluginStatus, StringContent +from openlp.core.lib import Receiver, Settings, PluginStatus, StringContent, Registry from openlp.core.utils import AppLocation, translate log = logging.getLogger(__name__) @@ -252,12 +252,11 @@ class HttpConnection(object): def _get_service_items(self): service_items = [] - service_manager = self.parent.plugin.serviceManager if self.parent.current_item: current_unique_identifier = self.parent.current_item.unique_identifier else: current_unique_identifier = None - for item in service_manager.serviceItems: + for item in self.service_manager.serviceItems: service_item = item[u'service_item'] service_items.append({ u'id': unicode(service_item.unique_identifier), @@ -388,13 +387,13 @@ class HttpConnection(object): Poll OpenLP to determine the current slide number and item name. """ result = { - u'service': self.parent.plugin.serviceManager.service_id, + u'service': self.service_manager.service_id, u'slide': self.parent.current_slide or 0, u'item': self.parent.current_item.unique_identifier if self.parent.current_item else u'', u'twelve':Settings().value(u'remotes/twelve hour'), - u'blank': self.parent.plugin.liveController.blankScreen.isChecked(), - u'theme': self.parent.plugin.liveController.themeScreen.isChecked(), - u'display': self.parent.plugin.liveController.desktopScreen.isChecked() + u'blank': self.live_controller.blankScreen.isChecked(), + u'theme': self.live_controller.themeScreen.isChecked(), + u'display': self.live_controller.desktopScreen.isChecked() } return HttpResponse(json.dumps({u'results': result}), {u'Content-Type': u'application/json'}) @@ -414,7 +413,7 @@ class HttpConnection(object): """ Send an alert. """ - plugin = self.parent.plugin.pluginManager.get_plugin_by_name("alerts") + plugin = self.plugin_manager.get_plugin_by_name("alerts") if plugin.status == PluginStatus.Active: try: text = json.loads(self.url_params[u'data'][0])[u'request'][u'text'] @@ -506,7 +505,7 @@ class HttpConnection(object): """ if action == u'search': searches = [] - for plugin in self.parent.plugin.pluginManager.plugins: + for plugin in self.plugin_manager.plugins: if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch: searches.append([plugin.name, unicode(plugin.textStrings[StringContent.Name][u'plural'])]) return HttpResponse( @@ -525,7 +524,7 @@ class HttpConnection(object): except KeyError, ValueError: return HttpResponse(code=u'400 Bad Request') text = urllib.unquote(text) - plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type) + plugin = self.plugin_manager.get_plugin_by_name(type) if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch: results = plugin.mediaItem.search(text, False) else: @@ -541,7 +540,7 @@ class HttpConnection(object): id = json.loads(self.url_params[u'data'][0])[u'request'][u'id'] except KeyError, ValueError: return HttpResponse(code=u'400 Bad Request') - plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type) + plugin = self.plugin_manager.get_plugin_by_name(type) if plugin.status == PluginStatus.Active and plugin.mediaItem: plugin.mediaItem.goLive(id, remote=True) return HttpResponse(code=u'200 OK') @@ -554,7 +553,7 @@ class HttpConnection(object): id = json.loads(self.url_params[u'data'][0])[u'request'][u'id'] except KeyError, ValueError: return HttpResponse(code=u'400 Bad Request') - plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type) + plugin = self.plugin_manager.get_plugin_by_name(type) if plugin.status == PluginStatus.Active and plugin.mediaItem: item_id = plugin.mediaItem.createItemFromId(id) plugin.mediaItem.addToService(item_id, remote=True) @@ -585,3 +584,33 @@ class HttpConnection(object): self.socket.close() self.socket = None self.parent.close_connection(self) + + def _get_service_manager(self): + """ + Adds the service manager to the class dynamically + """ + if not hasattr(self, u'_service_manager'): + self._service_manager = Registry().get(u'service_manager') + return self._service_manager + + service_manager = property(_get_service_manager) + + def _get_live_controller(self): + """ + Adds the live controller to the class dynamically + """ + if not hasattr(self, u'_live_controller'): + self._live_controller = Registry().get(u'live_controller') + return self._live_controller + + live_controller = property(_get_live_controller) + + def _get_plugin_manager(self): + """ + Adds the plugin manager to the class dynamically + """ + if not hasattr(self, u'_plugin_manager'): + self._plugin_manager = Registry().get(u'plugin_manager') + return self._plugin_manager + + plugin_manager = property(_get_plugin_manager) From ffe6bdb6b0cd735069a934105d300efbf980fdeb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 12 Feb 2013 08:49:59 +0100 Subject: [PATCH 22/31] removed blank line --- openlp/plugins/alerts/lib/alertsmanager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 42a28eee1..40910c67c 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -108,7 +108,6 @@ class AlertsManager(QtCore.QObject): self.timer_id = 0 self.generateAlert() - def _get_live_controller(self): """ Adds the live controller to the class dynamically From f419108e61440d018d97b2d0c351b42064f41c55 Mon Sep 17 00:00:00 2001 From: phill-ridout Date: Tue, 12 Feb 2013 19:26:19 +0000 Subject: [PATCH 23/31] Removed spacing from comments. --- tests/interfaces/openlp_core_ui/test_filerenamedialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py index 3e22b11e1..74fe83b26 100644 --- a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py +++ b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py @@ -79,5 +79,5 @@ class TestStartFileRenameForm(TestCase): QtTest.QTest.keyClicks(self.form.fileNameEdit, u'I/n\\v?a*l|i \F[i\l]e" :N+a%me') # THEN: The text in the QLineEdit should be the same as the input string with the invalid chatacters filtered - # out. + # out. self.assertEqual(self.form.fileNameEdit.text(), u'Invalid File Name') From bc5334fa1ac9885480c62936bf4624518180daf8 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 13 Feb 2013 19:10:41 +0000 Subject: [PATCH 24/31] Add new tests to system --- tests/functional/openlp_core_lib/__init__.py | 8 +++ .../openlp_core_lib/test_image_manager.py | 49 +++++++++++++++++++ tests/interfaces/openlp_core_ui/__init__.py | 8 +++ .../openlp_core_ui/test_servicemanager.py | 41 ++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 tests/functional/openlp_core_lib/test_image_manager.py create mode 100644 tests/interfaces/openlp_core_ui/test_servicemanager.py diff --git a/tests/functional/openlp_core_lib/__init__.py b/tests/functional/openlp_core_lib/__init__.py index e69de29bb..e0da50eb3 100644 --- a/tests/functional/openlp_core_lib/__init__.py +++ b/tests/functional/openlp_core_lib/__init__.py @@ -0,0 +1,8 @@ +import sip +sip.setapi(u'QDate', 2) +sip.setapi(u'QDateTime', 2) +sip.setapi(u'QString', 2) +sip.setapi(u'QTextStream', 2) +sip.setapi(u'QTime', 2) +sip.setapi(u'QUrl', 2) +sip.setapi(u'QVariant', 2) \ No newline at end of file diff --git a/tests/functional/openlp_core_lib/test_image_manager.py b/tests/functional/openlp_core_lib/test_image_manager.py new file mode 100644 index 000000000..2ab0ff1ce --- /dev/null +++ b/tests/functional/openlp_core_lib/test_image_manager.py @@ -0,0 +1,49 @@ +""" + Package to test the openlp.core.ui package. +""" + +import os + +from unittest import TestCase + +from mock import MagicMock +from openlp.core.lib import Registry, ImageManager, ScreenList +from PyQt4 import QtCore, QtGui, QtTest + +TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources')) + +class TestImageManager(TestCase): + + def setUp(self): + """ + Create the UI + """ + Registry.create() + self.app = QtGui.QApplication([]) + ScreenList.create(self.app.desktop()) + self.image_manager = ImageManager() + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.app + + def basic_image_manager_test(self): + """ + Test the Image Manager setup basic functionality + """ + # GIVEN: the an image add to the image manager + self.image_manager.add_image(TEST_PATH, u'church.jpg', None) + + # WHEN the image is retrieved + image = self.image_manager.get_image(TEST_PATH, u'church.jpg') + + # THEN returned record is a type of image + self.assertEqual(isinstance(image, QtGui.QImage), True, u'The returned field is an image') + + # WHEN the image is retrieved has not been loaded + # THEN a KeyError is thrown + with self.assertRaises(KeyError) as context: + self.image_manager.get_image(TEST_PATH, u'church1.jpg') + self.assertNotEquals(context.exception[0], u'', u'KeyError exception should have been thrown for missing image') \ No newline at end of file diff --git a/tests/interfaces/openlp_core_ui/__init__.py b/tests/interfaces/openlp_core_ui/__init__.py index e69de29bb..e0da50eb3 100644 --- a/tests/interfaces/openlp_core_ui/__init__.py +++ b/tests/interfaces/openlp_core_ui/__init__.py @@ -0,0 +1,8 @@ +import sip +sip.setapi(u'QDate', 2) +sip.setapi(u'QDateTime', 2) +sip.setapi(u'QString', 2) +sip.setapi(u'QTextStream', 2) +sip.setapi(u'QTime', 2) +sip.setapi(u'QUrl', 2) +sip.setapi(u'QVariant', 2) \ No newline at end of file diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py new file mode 100644 index 000000000..7883a5694 --- /dev/null +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -0,0 +1,41 @@ +""" + Package to test the openlp.core.ui package. +""" +from unittest import TestCase + +from mock import MagicMock +from openlp.core.lib import Registry, ScreenList +from openlp.core.ui.mainwindow import MainWindow +from PyQt4 import QtGui + + +class TestStartNoteDialog(TestCase): + + def setUp(self): + """ + Create the UI + """ + Registry.create() + self.app = QtGui.QApplication([]) + ScreenList.create(self.app.desktop()) + Registry().register(u'application', MagicMock()) + self.main_window = MainWindow() + self.service_manager = Registry().get(u'service_manager') + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.main_window + del self.app + + def basic_service_manager_test(self): + """ + Test the Service Manager display functionality + """ + # GIVEN: A New Service Manager instance + + # WHEN I have an empty display + # THEN the count of items should be zero + self.assertEqual(self.service_manager.service_manager_list.topLevelItemCount(), 0, + u'There the service manager list is empty ') From 89856e0e9aa660b6300fd88fa7622dc93f976890 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 13 Feb 2013 19:22:43 +0000 Subject: [PATCH 25/31] Cleanup --- tests/functional/openlp_core_lib/test_image_manager.py | 6 +++--- tests/interfaces/openlp_core_ui/__init__.py | 2 +- tests/interfaces/openlp_core_ui/test_servicemanager.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_image_manager.py b/tests/functional/openlp_core_lib/test_image_manager.py index 2ab0ff1ce..3ee4abd90 100644 --- a/tests/functional/openlp_core_lib/test_image_manager.py +++ b/tests/functional/openlp_core_lib/test_image_manager.py @@ -6,12 +6,12 @@ import os from unittest import TestCase -from mock import MagicMock from openlp.core.lib import Registry, ImageManager, ScreenList -from PyQt4 import QtCore, QtGui, QtTest +from PyQt4 import QtGui TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources')) + class TestImageManager(TestCase): def setUp(self): @@ -46,4 +46,4 @@ class TestImageManager(TestCase): # THEN a KeyError is thrown with self.assertRaises(KeyError) as context: self.image_manager.get_image(TEST_PATH, u'church1.jpg') - self.assertNotEquals(context.exception[0], u'', u'KeyError exception should have been thrown for missing image') \ No newline at end of file + self.assertNotEquals(context.exception[0], u'', u'KeyError exception should have been thrown for missing image') diff --git a/tests/interfaces/openlp_core_ui/__init__.py b/tests/interfaces/openlp_core_ui/__init__.py index e0da50eb3..0157fb2f0 100644 --- a/tests/interfaces/openlp_core_ui/__init__.py +++ b/tests/interfaces/openlp_core_ui/__init__.py @@ -5,4 +5,4 @@ sip.setapi(u'QString', 2) sip.setapi(u'QTextStream', 2) sip.setapi(u'QTime', 2) sip.setapi(u'QUrl', 2) -sip.setapi(u'QVariant', 2) \ No newline at end of file +sip.setapi(u'QVariant', 2) diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index 7883a5694..b894db470 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -1,5 +1,5 @@ """ - Package to test the openlp.core.ui package. + Package to test the openlp.core.lib package. """ from unittest import TestCase @@ -38,4 +38,4 @@ class TestStartNoteDialog(TestCase): # WHEN I have an empty display # THEN the count of items should be zero self.assertEqual(self.service_manager.service_manager_list.topLevelItemCount(), 0, - u'There the service manager list is empty ') + u'There the service manager list is not empty ') From a5b6b5fe90fc408514afc633977c07d82577193f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 14 Feb 2013 17:30:28 +0000 Subject: [PATCH 26/31] Fix init methods --- tests/functional/__init__.py | 8 ++++++++ tests/functional/openlp_core_lib/__init__.py | 8 -------- tests/interfaces/__init__.py | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 tests/functional/__init__.py create mode 100644 tests/interfaces/__init__.py diff --git a/tests/functional/__init__.py b/tests/functional/__init__.py new file mode 100644 index 000000000..e0da50eb3 --- /dev/null +++ b/tests/functional/__init__.py @@ -0,0 +1,8 @@ +import sip +sip.setapi(u'QDate', 2) +sip.setapi(u'QDateTime', 2) +sip.setapi(u'QString', 2) +sip.setapi(u'QTextStream', 2) +sip.setapi(u'QTime', 2) +sip.setapi(u'QUrl', 2) +sip.setapi(u'QVariant', 2) \ No newline at end of file diff --git a/tests/functional/openlp_core_lib/__init__.py b/tests/functional/openlp_core_lib/__init__.py index e0da50eb3..e69de29bb 100644 --- a/tests/functional/openlp_core_lib/__init__.py +++ b/tests/functional/openlp_core_lib/__init__.py @@ -1,8 +0,0 @@ -import sip -sip.setapi(u'QDate', 2) -sip.setapi(u'QDateTime', 2) -sip.setapi(u'QString', 2) -sip.setapi(u'QTextStream', 2) -sip.setapi(u'QTime', 2) -sip.setapi(u'QUrl', 2) -sip.setapi(u'QVariant', 2) \ No newline at end of file diff --git a/tests/interfaces/__init__.py b/tests/interfaces/__init__.py new file mode 100644 index 000000000..e0da50eb3 --- /dev/null +++ b/tests/interfaces/__init__.py @@ -0,0 +1,8 @@ +import sip +sip.setapi(u'QDate', 2) +sip.setapi(u'QDateTime', 2) +sip.setapi(u'QString', 2) +sip.setapi(u'QTextStream', 2) +sip.setapi(u'QTime', 2) +sip.setapi(u'QUrl', 2) +sip.setapi(u'QVariant', 2) \ No newline at end of file From 796a147ffe4dbb7601b9a152b055be32794d6bc8 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 14 Feb 2013 17:34:41 +0000 Subject: [PATCH 27/31] Remove one extra file --- tests/interfaces/openlp_core_ui/__init__.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/interfaces/openlp_core_ui/__init__.py b/tests/interfaces/openlp_core_ui/__init__.py index 0157fb2f0..8b1378917 100644 --- a/tests/interfaces/openlp_core_ui/__init__.py +++ b/tests/interfaces/openlp_core_ui/__init__.py @@ -1,8 +1 @@ -import sip -sip.setapi(u'QDate', 2) -sip.setapi(u'QDateTime', 2) -sip.setapi(u'QString', 2) -sip.setapi(u'QTextStream', 2) -sip.setapi(u'QTime', 2) -sip.setapi(u'QUrl', 2) -sip.setapi(u'QVariant', 2) + From 11dea519d2db5b726c9ccf92e764153c259af166 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 16 Feb 2013 06:51:25 +0000 Subject: [PATCH 28/31] Fix import order --- tests/functional/openlp_core_lib/test_image_manager.py | 5 +++-- tests/functional/openlp_core_lib/test_registry.py | 3 ++- tests/functional/openlp_core_lib/test_serviceitem.py | 3 +-- tests/interfaces/openlp_core_ui/test_servicemanager.py | 6 ++++-- tests/interfaces/openlp_core_ui/test_servicenotedialog.py | 6 ++++-- tests/interfaces/openlp_core_ui/test_starttimedialog.py | 6 ++++-- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_image_manager.py b/tests/functional/openlp_core_lib/test_image_manager.py index 3ee4abd90..a8fcdfa59 100644 --- a/tests/functional/openlp_core_lib/test_image_manager.py +++ b/tests/functional/openlp_core_lib/test_image_manager.py @@ -3,12 +3,13 @@ """ import os - from unittest import TestCase -from openlp.core.lib import Registry, ImageManager, ScreenList from PyQt4 import QtGui +from openlp.core.lib import Registry, ImageManager, ScreenList + + TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources')) diff --git a/tests/functional/openlp_core_lib/test_registry.py b/tests/functional/openlp_core_lib/test_registry.py index a2fe60627..7bb7c84cf 100644 --- a/tests/functional/openlp_core_lib/test_registry.py +++ b/tests/functional/openlp_core_lib/test_registry.py @@ -2,13 +2,14 @@ Package to test the openlp.core.lib package. """ import os - from unittest import TestCase from mock import MagicMock + from openlp.core.lib import Registry TESTPATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources')) + class TestRegistry(TestCase): def registry_service_test(self): diff --git a/tests/functional/openlp_core_lib/test_serviceitem.py b/tests/functional/openlp_core_lib/test_serviceitem.py index a50752cce..05952471d 100644 --- a/tests/functional/openlp_core_lib/test_serviceitem.py +++ b/tests/functional/openlp_core_lib/test_serviceitem.py @@ -3,10 +3,9 @@ """ import os import cPickle - from unittest import TestCase - from mock import MagicMock + from openlp.core.lib import ServiceItem, Registry diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index b894db470..8ecf3271d 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -1,12 +1,14 @@ """ Package to test the openlp.core.lib package. """ -from unittest import TestCase +from unittest import TestCase from mock import MagicMock + +from PyQt4 import QtGui + from openlp.core.lib import Registry, ScreenList from openlp.core.ui.mainwindow import MainWindow -from PyQt4 import QtGui class TestStartNoteDialog(TestCase): diff --git a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py index f3694fdea..1cf3fef38 100644 --- a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py +++ b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py @@ -2,11 +2,13 @@ Package to test the openlp.core.ui package. """ from unittest import TestCase - from mock import patch + +from PyQt4 import QtCore, QtGui, QtTest + from openlp.core.lib import Registry from openlp.core.ui import servicenoteform -from PyQt4 import QtCore, QtGui, QtTest + class TestStartNoteDialog(TestCase): diff --git a/tests/interfaces/openlp_core_ui/test_starttimedialog.py b/tests/interfaces/openlp_core_ui/test_starttimedialog.py index a9b33a30c..888402235 100644 --- a/tests/interfaces/openlp_core_ui/test_starttimedialog.py +++ b/tests/interfaces/openlp_core_ui/test_starttimedialog.py @@ -2,11 +2,13 @@ Package to test the openlp.core.ui package. """ from unittest import TestCase - from mock import MagicMock, patch + +from PyQt4 import QtCore, QtGui, QtTest + from openlp.core.lib import Registry from openlp.core.ui import starttimeform -from PyQt4 import QtCore, QtGui, QtTest + class TestStartTimeDialog(TestCase): From 60eed1018f72da3d37c5181a2acdfe53784a4a14 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 16 Feb 2013 10:24:06 +0100 Subject: [PATCH 29/31] fixed merge errors --- openlp/plugins/alerts/forms/alertform.py | 2 +- openlp/plugins/alerts/lib/alertsmanager.py | 2 +- openlp/plugins/images/imageplugin.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index c09180702..aba13ddb9 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -199,7 +199,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.parameterEdit.setFocus() return False text = text.replace(u'<>', self.parameterEdit.text()) - self.plugin.alertsmanager.displayAlert(text) + self.plugin.alertsmanager.display_alert(text) return True def onCurrentRowChanged(self, row): diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index b4516cdd5..6db4f2d70 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -108,7 +108,7 @@ class AlertsManager(QtCore.QObject): self.live_controller.display.alert(u'', alertTab.location) self.killTimer(self.timer_id) self.timer_id = 0 - self.generateAlert() + self.generate_alert() def _get_live_controller(self): """ diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 6b7705e48..61cc29e01 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt4 import QtGui import logging From 8ad83b52ba747de808440af5bf8a089e0958d39d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 16 Feb 2013 10:15:49 +0000 Subject: [PATCH 30/31] Text fix --- tests/functional/openlp_core_lib/test_image_manager.py | 2 +- tests/interfaces/openlp_core_ui/test_servicemanager.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_image_manager.py b/tests/functional/openlp_core_lib/test_image_manager.py index a8fcdfa59..d13c82c04 100644 --- a/tests/functional/openlp_core_lib/test_image_manager.py +++ b/tests/functional/openlp_core_lib/test_image_manager.py @@ -41,7 +41,7 @@ class TestImageManager(TestCase): image = self.image_manager.get_image(TEST_PATH, u'church.jpg') # THEN returned record is a type of image - self.assertEqual(isinstance(image, QtGui.QImage), True, u'The returned field is an image') + self.assertEqual(isinstance(image, QtGui.QImage), True, u'The returned object should be a QImage') # WHEN the image is retrieved has not been loaded # THEN a KeyError is thrown diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index 8ecf3271d..778387ab1 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -40,4 +40,4 @@ class TestStartNoteDialog(TestCase): # WHEN I have an empty display # THEN the count of items should be zero self.assertEqual(self.service_manager.service_manager_list.topLevelItemCount(), 0, - u'There the service manager list is not empty ') + u'The service manager list is not empty ') From 454f42884507adfe01606f0de4fde2a38e867c64 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 16 Feb 2013 10:17:48 +0000 Subject: [PATCH 31/31] Text fix --- tests/interfaces/openlp_core_ui/test_servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index 778387ab1..bb62bd6e6 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -40,4 +40,4 @@ class TestStartNoteDialog(TestCase): # WHEN I have an empty display # THEN the count of items should be zero self.assertEqual(self.service_manager.service_manager_list.topLevelItemCount(), 0, - u'The service manager list is not empty ') + u'The service manager list should be empty ')