From 400595adf5746c33db2938db27260ff1d169925a Mon Sep 17 00:00:00 2001 From: Olli Suutari Date: Tue, 4 Oct 2016 11:43:52 +0300 Subject: [PATCH] - Fixed tests for creating creator lists --- tests/functional/openlp_core_lib/test_lib.py | 50 ++++++++------------ 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 145be21f4..05c2b8a28 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -689,50 +689,38 @@ class TestLib(TestCase): """ Test the create_separated_list function with a list consisting of only one entry """ - with patch('openlp.core.lib.Qt') as mocked_qt: - # GIVEN: A list with a string and the mocked Qt module. - mocked_qt.PYQT_VERSION_STR = '4.8' - mocked_qt.qVersion.return_value = '4.7' - string_list = ['Author 1'] + # GIVEN: A list with a string. + string_list = ['Author 1'] - # WHEN: We get a string build from the entries it the list and a separator. - string_result = create_separated_list(string_list) + # WHEN: We get a string build from the entries it the list and a separator. + string_result = create_separated_list(string_list) - # THEN: We should have "Author 1" - assert string_result == 'Author 1', 'The string should be u\'Author 1\'.' + # THEN: We should have "Author 1" + assert string_result == 'Author 1', 'The string should be u\'Author 1\'.' def test_create_separated_list_with_two_items(self): """ Test the create_separated_list function with a list of two entries """ - with patch('openlp.core.lib.Qt') as mocked_qt, patch('openlp.core.lib.translate') as mocked_translate: - # GIVEN: A list of strings and the mocked Qt module. - mocked_qt.PYQT_VERSION_STR = '4.8' - mocked_qt.qVersion.return_value = '4.7' - mocked_translate.return_value = '%s and %s' - string_list = ['Author 1', 'Author 2'] + # GIVEN: A list with two strings. + string_list = ['Author 1', 'Author 2'] - # WHEN: We get a string build from the entries it the list and a seperator. - string_result = create_separated_list(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: We should have "Author 1 and Author 2" - assert string_result == 'Author 1 and Author 2', 'The string should be u\'Author 1 and Author 2\'.' + # THEN: We should have "Author 1 and Author 2" + assert string_result == 'Author 1 and Author 2', 'The string should be u\'Author 1 and Author 2\'.' def test_create_separated_list_with_three_items(self): """ Test the create_separated_list function with a list of three items """ - with patch('openlp.core.lib.Qt') as mocked_qt, patch('openlp.core.lib.translate') as mocked_translate: - # GIVEN: A list with a string and the mocked Qt module. - mocked_qt.PYQT_VERSION_STR = '4.8' - mocked_qt.qVersion.return_value = '4.7' - # Always return the untranslated string. - mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate - string_list = ['Author 1', 'Author 2', 'Author 3'] + # GIVEN: A list with three strings. + string_list = ['Author 1', 'Author 2', 'Author 3'] - # WHEN: We get a string build from the entries it the list and a seperator. - string_result = create_separated_list(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: We should have "Author 1, Author 2, and Author 3" - assert string_result == 'Author 1, Author 2, and Author 3', 'The string should be u\'Author 1, ' \ - 'Author 2, and Author 3\'.' + # THEN: We should have "Author 1, Author 2, and Author 3" + assert string_result == 'Author 1, Author 2, and Author 3', 'The string should be u\'Author 1, ' \ + 'Author 2, and Author 3\'.'