This commit is contained in:
Tim Bentley 2014-04-02 20:35:09 +01:00
parent 806ce25296
commit 151f1017c5
34 changed files with 128 additions and 133 deletions

View File

@ -119,4 +119,3 @@ class TestRegistry(TestCase):
def dummy_function_2(self):
return "function_2"

View File

@ -63,4 +63,4 @@ class TestRegistryProperties(TestCase, RegistryProperties):
# WHEN the application is registered
Registry().register('application', application)
# THEN the application should be none
self.assertEquals(self.application, application, 'The application value should match')
self.assertEquals(self.application, application, 'The application value should match')

View File

@ -46,5 +46,3 @@ class TestUiStrings(TestCase):
# THEN: Check if the instances are the same.
self.assertIs(first_instance, second_instance, 'Two UiStrings objects should be the same instance')

View File

@ -72,9 +72,10 @@ class TestFormattingTagController(TestCase):
# THEN: The result should match the predetermined value.
self.assertTrue(result == test['gen'],
'Function should handle end tag correctly : %s and %s for %s ' % (test['gen'], result, test['start']))
self.assertTrue(error == test['valid'],
'Function should not generate unexpected error messages : %s ' % error)
'Function should handle end tag correctly : %s and %s for %s ' %
(test['gen'], result, test['start']))
self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' %
error)
def test_start_tag_changed_processes_correctly(self):
"""
@ -94,10 +95,10 @@ class TestFormattingTagController(TestCase):
error, result = self.services.start_tag_changed(test['start'], test['end'])
# THEN: The result should match the predetermined value.
self.assertTrue(result == test['gen'],
'Function should handle end tag correctly : %s and %s ' % (test['gen'], result))
self.assertTrue(error == test['valid'],
'Function should not generate unexpected error messages : %s ' % error)
self.assertTrue(result == test['gen'], 'Function should handle end tag correctly : %s and %s ' %
(test['gen'], result))
self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' %
error)
def test_start_html_to_end_html(self):
"""
@ -112,5 +113,5 @@ class TestFormattingTagController(TestCase):
result = self.services.start_html_to_end_html(test1)
# THEN: The result should match the predetermined value.
self.assertTrue(result == test2, 'Calculated end tag should be valid: %s and %s = %s'
% (test1, test2, result))
self.assertTrue(result == test2, 'Calculated end tag should be valid: %s and %s = %s' %
(test1, test2, result))

View File

@ -74,4 +74,3 @@ class TestFormattingTagForm(TestCase):
# THEN: setEnabled and setDefault should have been called on save_push_button
#form.save_button.setEnabled.assert_called_with(True)

View File

@ -74,4 +74,4 @@ class TestServiceManager(TestCase):
# THEN: The the controller should be registered in the registry.
self.assertNotEqual(service, None, 'The base service should be created')
self.assertEqual(service['openlp_core']['service-theme'], 'test_theme', 'The test theme should be saved')
self.assertEqual(service['openlp_core']['lite-service'], False, 'The lite service should be saved')
self.assertEqual(service['openlp_core']['lite-service'], False, 'The lite service should be saved')

View File

@ -149,5 +149,3 @@ class TestActionList(TestCase, TestMixin):
# THEN: Both action should keep their shortcuts.
assert len(action3.shortcuts()) == 2, 'The action should have two shortcut assigned.'
assert len(action_with_same_shortcuts3.shortcuts()) == 2, 'The action should have two shortcuts assigned.'

View File

@ -107,7 +107,7 @@ class TestUtils(TestCase):
"""
# GIVEN: sys.getfilesystemencoding returns "cp1252"
with patch('openlp.core.utils.sys.getfilesystemencoding') as mocked_getfilesystemencoding, \
patch('openlp.core.utils.sys.getdefaultencoding') as mocked_getdefaultencoding:
patch('openlp.core.utils.sys.getdefaultencoding') as mocked_getdefaultencoding:
mocked_getfilesystemencoding.return_value = 'cp1252'
# WHEN: get_filesystem_encoding() is called
@ -124,7 +124,7 @@ class TestUtils(TestCase):
"""
# GIVEN: sys.getfilesystemencoding returns None and sys.getdefaultencoding returns "utf-8"
with patch('openlp.core.utils.sys.getfilesystemencoding') as mocked_getfilesystemencoding, \
patch('openlp.core.utils.sys.getdefaultencoding') as mocked_getdefaultencoding:
patch('openlp.core.utils.sys.getdefaultencoding') as mocked_getdefaultencoding:
mocked_getfilesystemencoding.return_value = None
mocked_getdefaultencoding.return_value = 'utf-8'
@ -175,7 +175,7 @@ class TestUtils(TestCase):
# THEN: A tuple should be returned.
self.assertEqual(wanted_result, result,
'A two-entry tuple with the directory and file name (empty) should have been returned.')
'A two-entry tuple with the directory and file name (empty) should have been returned.')
def clean_filename_test(self):
"""
@ -206,7 +206,7 @@ class TestUtils(TestCase):
# THEN: We get a properly sorted list
self.assertEqual(['Aushang', '\u00C4u\u00DFerung', 'Auszug'], sorted_list,
'Strings should be sorted properly')
'Strings should be sorted properly')
def get_natural_key_test(self):
"""

View File

@ -25,4 +25,4 @@
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
###############################################################################

View File

@ -80,7 +80,8 @@ class TestPptviewController(TestCase, TestMixin):
controller = PptviewController(plugin=self.mock_plugin)
# THEN: The name of the presentation controller should be correct
self.assertEqual('Powerpoint Viewer', controller.name, 'The name of the presentation controller should be correct')
self.assertEqual('Powerpoint Viewer', controller.name,
'The name of the presentation controller should be correct')
def check_available_test(self):
"""
@ -98,9 +99,9 @@ class TestPptviewController(TestCase, TestMixin):
# THEN: On windows it should return True, on other platforms False
if os.name == 'nt':
self.assertTrue(available, 'check_available should return True on windows.')
self.assertTrue(available, 'check_available should return True on windows.')
else:
self.assertFalse(available, 'check_available should return False when not on windows.')
self.assertFalse(available, 'check_available should return False when not on windows.')
class TestPptviewDocument(TestCase):

View File

@ -25,4 +25,4 @@
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
###############################################################################

View File

@ -111,7 +111,8 @@ class TestRouter(TestCase, TestMixin):
Test the get_content_type logic
"""
# GIVEN: a set of files and their corresponding types
headers = [ ['test.html', 'text/html'], ['test.css', 'text/css'],
headers = [
['test.html', 'text/html'], ['test.css', 'text/css'],
['test.js', 'application/javascript'], ['test.jpg', 'image/jpeg'],
['test.gif', 'image/gif'], ['test.ico', 'image/x-icon'],
['test.png', 'image/png'], ['test.whatever', 'text/plain'],
@ -142,7 +143,7 @@ class TestRouter(TestCase, TestMixin):
# THEN: it should return a 404
self.router.send_response.assert_called_once_with(404)
self.router.send_header.assert_called_once_with('Content-type','text/html')
self.router.send_header.assert_called_once_with('Content-type', 'text/html')
self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers called once')
def serve_file_with_valid_params_test(self):

View File

@ -41,33 +41,33 @@ TEST_PATH = os.path.abspath(
os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'easyworshipsongs'))
SONG_TEST_DATA = [
{'title': 'Amazing Grace',
'authors': ['John Newton'],
'copyright': 'Public Domain',
'ccli_number': 0,
'verses':
[('Amazing grace how sweet the sound,\nThat saved a wretch like me;\n'
'I once was lost, but now am found\nWas blind, but now I see.', 'v1'),
('T\'was grace that taught my heart to fear,\nAnd grace my fears relieved;\n'
'How precious did that grace appear\nThe hour I first believed.', 'v2'),
('Through many dangers, toil and snares,\nI have already come;\n'
'\'Tis grace has brought me safe thus far,\nAnd grace will lead me home.', 'v3'),
('When we\'ve been there ten thousand years\nBright shining as the sun,\n'
'We\'ve no less days to sing God\'s praise\nThan when we\'ve first begun.', 'v4')],
'verse_order_list': []},
'authors': ['John Newton'],
'copyright': 'Public Domain',
'ccli_number': 0,
'verses':
[('Amazing grace how sweet the sound,\nThat saved a wretch like me;\n'
'I once was lost, but now am found\nWas blind, but now I see.', 'v1'),
('T\'was grace that taught my heart to fear,\nAnd grace my fears relieved;\n'
'How precious did that grace appear\nThe hour I first believed.', 'v2'),
('Through many dangers, toil and snares,\nI have already come;\n'
'\'Tis grace has brought me safe thus far,\nAnd grace will lead me home.', 'v3'),
('When we\'ve been there ten thousand years\nBright shining as the sun,\n'
'We\'ve no less days to sing God\'s praise\nThan when we\'ve first begun.', 'v4')],
'verse_order_list': []},
{'title': 'Beautiful Garden Of Prayer',
'authors': ['Eleanor Allen Schroll James H. Fillmore'],
'copyright': 'Public Domain',
'ccli_number': 0,
'verses':
[('O the beautiful garden, the garden of prayer,\nO the beautiful garden of prayer.\n'
'There my Savior awaits, and He opens the gates\nTo the beautiful garden of prayer.', 'c1'),
('There\'s a garden where Jesus is waiting,\nThere\'s a place that is wondrously fair.\n'
'For it glows with the light of His presence,\n\'Tis the beautiful garden of prayer.', 'v1'),
('There\'s a garden where Jesus is waiting,\nAnd I go with my burden and care.\n'
'Just to learn from His lips, words of comfort,\nIn the beautiful garden of prayer.', 'v2'),
('There\'s a garden where Jesus is waiting,\nAnd He bids you to come meet Him there,\n'
'Just to bow and receive a new blessing,\nIn the beautiful garden of prayer.', 'v3')],
'verse_order_list': []}]
'authors': ['Eleanor Allen Schroll James H. Fillmore'],
'copyright': 'Public Domain',
'ccli_number': 0,
'verses':
[('O the beautiful garden, the garden of prayer,\nO the beautiful garden of prayer.\n'
'There my Savior awaits, and He opens the gates\nTo the beautiful garden of prayer.', 'c1'),
('There\'s a garden where Jesus is waiting,\nThere\'s a place that is wondrously fair.\n'
'For it glows with the light of His presence,\n\'Tis the beautiful garden of prayer.', 'v1'),
('There\'s a garden where Jesus is waiting,\nAnd I go with my burden and care.\n'
'Just to learn from His lips, words of comfort,\nIn the beautiful garden of prayer.', 'v2'),
('There\'s a garden where Jesus is waiting,\nAnd He bids you to come meet Him there,\n'
'Just to bow and receive a new blessing,\nIn the beautiful garden of prayer.', 'v3')],
'verse_order_list': []}]
class EasyWorshipSongImportLogger(EasyWorshipSongImport):
@ -95,26 +95,32 @@ class TestFieldDesc:
self.size = size
TEST_DATA_ENCODING = 'cp1252'
CODE_PAGE_MAPPINGS = [(852, 'cp1250'), (737, 'cp1253'), (775, 'cp1257'), (855, 'cp1251'), (857, 'cp1254'),
CODE_PAGE_MAPPINGS = [
(852, 'cp1250'), (737, 'cp1253'), (775, 'cp1257'), (855, 'cp1251'), (857, 'cp1254'),
(866, 'cp1251'), (869, 'cp1253'), (862, 'cp1255'), (874, 'cp874')]
TEST_FIELD_DESCS = [TestFieldDesc('Title', FieldType.String, 50),
TEST_FIELD_DESCS = [
TestFieldDesc('Title', FieldType.String, 50),
TestFieldDesc('Text Percentage Bottom', FieldType.Int16, 2), TestFieldDesc('RecID', FieldType.Int32, 4),
TestFieldDesc('Default Background', FieldType.Logical, 1), TestFieldDesc('Words', FieldType.Memo, 250),
TestFieldDesc('Words', FieldType.Memo, 250), TestFieldDesc('BK Bitmap', FieldType.Blob, 10),
TestFieldDesc('Last Modified', FieldType.Timestamp, 10)]
TEST_FIELDS = [b'A Heart Like Thine\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', 32868, 2147483750,
TEST_FIELDS = [
b'A Heart Like Thine\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', 32868, 2147483750,
129, b'{\\rtf1\\ansi\\deff0\\deftab254{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}{\\f1\\fnil\\fcharset0 Verdana;}}'
b'{\\colortbl\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0\\blue255;'
b'\\red255\\green255\\blue0;\\red255\\green0\\blue255;\\red128\\g\xBF\xBD\7\0f\r\0\0\1\0',
b'{\\rtf1\\ansi\\deff0\\deftab254{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}{\\f1\\fnil\\fcharset0 Verdana;}}'
b'{\\colortbl\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0\\blue255;\\red255'
b'\\green255\\blue0;\\red255\\green0\\blue255;\\red128\\g\6\0\xEF\xBF\xBD\6\0\0\1\0', b'\0\0\0\0\0\0\0\0\0\0', 0]
b'{\\colortbl\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0\\blue255;'
b'\\red255\\green255\\blue0;\\red255\\green0\\blue255;\\red128\\g\xBF\xBD\7\0f\r\0\0\1\0',
b'{\\rtf1\\ansi\\deff0\\deftab254{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}{\\f1\\fnil\\fcharset0 Verdana;}}'
b'{\\colortbl\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0'
b'\\blue255;\\red255'
b'\\green255\\blue0;\\red255\\green0\\blue255;\\red128\\g\6\0\xEF\xBF\xBD\6\0\0\1\0',
b'\0\0\0\0\0\0\0\0\0\0', 0]
GET_MEMO_FIELD_TEST_RESULTS = [
(4, b'\2', {'return': b'\2','read': (1, 3430), 'seek': (507136, (8, os.SEEK_CUR))}),
(4, b'\2', {'return': b'\2', 'read': (1, 3430), 'seek': (507136, (8, os.SEEK_CUR))}),
(4, b'\3', {'return': b'', 'read': (1, ), 'seek': (507136, )}),
(5, b'\3', {'return': b'\3', 'read': (1, 1725), 'seek': (3220111360, (41, os.SEEK_CUR), 3220111408)}),
(5, b'\4', {'return': b'', 'read': (), 'seek': ()})]
class TestEasyWorshipSongImport(TestCase):
"""
Test the functions in the :mod:`ewimport` module.
@ -135,7 +141,7 @@ class TestEasyWorshipSongImport(TestCase):
self.assertIsNotNone(field_desc_entry, 'Import should not be none')
self.assertEquals(field_desc_entry.name, name, 'FieldDescEntry.name should be the same as the name argument')
self.assertEquals(field_desc_entry.field_type, field_type,
'FieldDescEntry.type should be the same as the typeargument')
'FieldDescEntry.type should be the same as the type argument')
self.assertEquals(field_desc_entry.size, size, 'FieldDescEntry.size should be the same as the size argument')
def create_importer_test(self):
@ -164,7 +170,7 @@ class TestEasyWorshipSongImport(TestCase):
# WHEN: Called with a field name that exists
existing_fields = ['Title', 'Text Percentage Bottom', 'RecID', 'Default Background', 'Words',
'BK Bitmap', 'Last Modified']
'BK Bitmap', 'Last Modified']
for field_name in existing_fields:
# THEN: The item corresponding the index returned should have the same name attribute
@ -194,7 +200,7 @@ class TestEasyWorshipSongImport(TestCase):
# GIVEN: A mocked out SongImport class, a mocked out struct class, and a mocked out "manager" and a list of
# field descriptions
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct:
patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct:
mocked_manager = MagicMock()
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
@ -225,7 +231,8 @@ class TestEasyWorshipSongImport(TestCase):
# THEN: get_field should return the known results
self.assertEquals(return_value, result,
'get_field should return "%s" when called with "%s"' % (result, TEST_FIELDS[field_index]))
'get_field should return "%s" when called with "%s"' %
(result, TEST_FIELDS[field_index]))
def get_memo_field_test(self):
"""
@ -265,7 +272,7 @@ class TestEasyWorshipSongImport(TestCase):
"""
# GIVEN: A mocked out SongImport class, a mocked out "manager"
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path:
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path:
mocked_manager = MagicMock()
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
mocked_os_path.isfile.side_effect = [True, False]
@ -284,7 +291,7 @@ class TestEasyWorshipSongImport(TestCase):
"""
# GIVEN: A mocked out SongImport class, os.path and a mocked out "manager"
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path:
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path:
mocked_manager = MagicMock()
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
mocked_os_path.isfile.return_value = True
@ -305,7 +312,7 @@ class TestEasyWorshipSongImport(TestCase):
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path, \
patch('builtins.open') as mocked_open, \
patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct:
patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct:
mocked_manager = MagicMock()
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
mocked_os_path.isfile.return_value = True
@ -320,7 +327,7 @@ class TestEasyWorshipSongImport(TestCase):
for effect in struct_unpack_return_values:
self.assertIsNone(importer.do_import(), 'do_import should return None when db_size is less than 0x800')
self.assertEqual(mocked_open().close.call_count, 2,
'The open db and memo files should have been closed')
'The open db and memo files should have been closed')
mocked_open().close.reset_mock()
self.assertIs(mocked_open().seek.called, False, 'db_file.seek should not have been called.')
@ -332,7 +339,8 @@ class TestEasyWorshipSongImport(TestCase):
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path, \
patch('builtins.open'), patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct, \
patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as mocked_retrieve_windows_encoding:
patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as \
mocked_retrieve_windows_encoding:
mocked_manager = MagicMock()
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
mocked_os_path.isfile.return_value = True
@ -357,7 +365,8 @@ class TestEasyWorshipSongImport(TestCase):
# GIVEN: Test files with a mocked out SongImport class, a mocked out "manager", a mocked out "import_wizard",
# and mocked out "author", "add_copyright", "add_verse", "finish" methods.
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as mocked_retrieve_windows_encoding:
patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as \
mocked_retrieve_windows_encoding:
mocked_retrieve_windows_encoding.return_value = 'cp1252'
mocked_manager = MagicMock()
mocked_import_wizard = MagicMock()
@ -395,10 +404,10 @@ class TestEasyWorshipSongImport(TestCase):
self.assertEqual(importer.copyright, song_copyright)
if ccli_number:
self.assertEquals(importer.ccli_number, ccli_number, 'ccli_number for %s should be %s'
% (title, ccli_number))
% (title, ccli_number))
for verse_text, verse_tag in add_verse_calls:
mocked_add_verse.assert_any_call(verse_text, verse_tag)
if verse_order_list:
self.assertEquals(importer.verse_order_list, verse_order_list, 'verse_order_list for %s should be %s'
% (title, verse_order_list))
self.assertEquals(importer.verse_order_list, verse_order_list,
'verse_order_list for %s should be %s' % (title, verse_order_list))
mocked_finish.assert_called_with()

View File

@ -44,20 +44,20 @@ class TestLib(TestCase):
"""
Mock up two songs and provide a set of lyrics for the songs_probably_equal tests.
"""
self.full_lyrics ='''amazing grace how sweet the sound that saved a wretch like me i once was lost but now am
self.full_lyrics = '''amazing grace how sweet the sound that saved a wretch like me i once was lost but now am
found was blind but now i see twas grace that taught my heart to fear and grace my fears relieved how
precious did that grace appear the hour i first believed through many dangers toils and snares i have already
come tis grace that brought me safe thus far and grace will lead me home'''
self.short_lyrics ='''twas grace that taught my heart to fear and grace my fears relieved how precious did that
grace appear the hour i first believed'''
self.error_lyrics ='''amazing how sweet the trumpet that saved a wrench like me i once was losst but now am
precious did that grace appear the hour i first believed through many dangers toils and snares i have
already come tis grace that brought me safe thus far and grace will lead me home'''
self.short_lyrics = '''twas grace that taught my heart to fear and grace my fears relieved how precious did
that grace appear the hour i first believed'''
self.error_lyrics = '''amazing how sweet the trumpet that saved a wrench like me i once was losst but now am
found waf blind but now i see it was grace that taught my heart to fear and grace my fears relieved how
precious did that grace appppppppear the hour i first believedxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx snares i have
already come to this grace that brought me safe so far and grace will lead me home'''
self.different_lyrics='''on a hill far away stood an old rugged cross the emblem of suffering and shame and i love
that old cross where the dearest and best for a world of lost sinners was slain so ill cherish the old rugged
cross till my trophies at last i lay down i will cling to the old rugged cross and exchange it some day for a
crown'''
self.different_lyrics = '''on a hill far away stood an old rugged cross the emblem of suffering and shame and
i love that old cross where the dearest and best for a world of lost sinners was slain so ill cherish the
old rugged cross till my trophies at last i lay down i will cling to the old rugged cross and exchange it
some day for a crown'''
self.song1 = MagicMock()
self.song2 = MagicMock()
@ -99,7 +99,7 @@ class TestLib(TestCase):
result = songs_probably_equal(self.song1, self.song2)
# THEN: The result should be True.
assert result == True, 'The result should be True'
assert result is True, 'The result should be True'
def songs_probably_equal_short_song_test(self):
"""
@ -113,7 +113,7 @@ class TestLib(TestCase):
result = songs_probably_equal(self.song1, self.song2)
# THEN: The result should be True.
assert result == True, 'The result should be True'
assert result is True, 'The result should be True'
def songs_probably_equal_error_song_test(self):
"""
@ -127,7 +127,7 @@ class TestLib(TestCase):
result = songs_probably_equal(self.song1, self.song2)
# THEN: The result should be True.
assert result == True, 'The result should be True'
assert result is True, 'The result should be True'
def songs_probably_equal_different_song_test(self):
"""
@ -141,7 +141,7 @@ class TestLib(TestCase):
result = songs_probably_equal(self.song1, self.song2)
# THEN: The result should be False.
assert result == False, 'The result should be False'
assert result is False, 'The result should be False'
def remove_typos_beginning_test(self):
"""
@ -267,8 +267,8 @@ class TestLib(TestCase):
# WHEN: We call strip_rtf on the input RTF
result, result_enc = strip_rtf(
'{\\rtf1 \\ansi \\ansicpg1252 {\\fonttbl \\f0 \\fswiss \\fcharset%s Helvetica;}' \
'{\\colortbl ;\\red0 \\green0 \\blue0 ;}\\pard \\f0 %s}' % (charset, input))
'{\\rtf1 \\ansi \\ansicpg1252 {\\fonttbl \\f0 \\fswiss \\fcharset%s Helvetica;}'
'{\\colortbl ;\\red0 \\green0 \\blue0 ;}\\pard \\f0 %s}' % (charset, input))
# THEN: The stripped text matches thed expected result
assert result == exp_result, 'The result should be %s' % exp_result

View File

@ -110,7 +110,7 @@ class TestSongBeamerImport(TestCase):
# THEN: do_import should return none and the progress bar setMaximum should be called with the length of
# import_source.
self.assertIsNone(importer.do_import(),
'do_import should return None when import_source is a list and stop_import_flag is True')
'do_import should return None when import_source is a list and stop_import_flag is True')
mocked_import_wizard.progress_bar.setMaximum.assert_called_with(len(importer.import_source))
def file_import_test(self):
@ -147,9 +147,9 @@ class TestSongBeamerImport(TestCase):
for verse_text, verse_tag in add_verse_calls:
mocked_add_verse.assert_any_call(verse_text, verse_tag)
if song_book_name:
self.assertEquals(importer.song_book_name, song_book_name, 'song_book_name for %s should be "%s"'
% (song_file, song_book_name))
self.assertEquals(importer.song_book_name, song_book_name, 'song_book_name for %s should be "%s"' %
(song_file, song_book_name))
if song_number:
self.assertEquals(importer.song_number, song_number, 'song_number for %s should be %s'
% (song_file, song_number))
self.assertEquals(importer.song_number, song_number, 'song_number for %s should be %s' %
(song_file, song_number))
mocked_finish.assert_called_with()

View File

@ -352,7 +352,7 @@ class TestSongSelect(TestCase):
"""
# GIVEN: A song to save, and some mocked out objects
with patch('openlp.plugins.songs.lib.songselect.clean_song') as mocked_clean_song, \
patch('openlp.plugins.songs.lib.songselect.Author') as MockedAuthor:
patch('openlp.plugins.songs.lib.songselect.Author') as MockedAuthor:
song_dict = {
'title': 'Arky Arky',
'authors': ['Public Domain'],

View File

@ -129,7 +129,8 @@ class TestSongShowPlusImport(TestCase):
importer = SongShowPlusImport(mocked_manager, filenames=[])
# WHEN: Supplied with the following arguments replicating verses being added
test_values = [('Verse 1', VerseType.tags[VerseType.Verse] + '1'),
test_values = [
('Verse 1', VerseType.tags[VerseType.Verse] + '1'),
('Verse 2', VerseType.tags[VerseType.Verse] + '2'),
('verse1', VerseType.tags[VerseType.Verse] + '1'),
('Verse', VerseType.tags[VerseType.Verse] + '1'),
@ -156,7 +157,8 @@ class TestSongShowPlusImport(TestCase):
importer = SongShowPlusImport(mocked_manager, filenames=[])
# WHEN: Supplied with the following arguments replicating a verse order being added
test_values = [('Verse 1', VerseType.tags[VerseType.Verse] + '1'),
test_values = [
('Verse 1', VerseType.tags[VerseType.Verse] + '1'),
('Verse 2', VerseType.tags[VerseType.Verse] + '2'),
('verse1', VerseType.tags[VerseType.Verse] + '1'),
('Verse', VerseType.tags[VerseType.Verse] + '1'),

View File

@ -204,8 +204,8 @@ class TestWorshipCenterProSongImport(TestCase):
# WHEN: Calling the do_import method
return_value = importer.do_import()
# THEN: do_import should return None, and pyodbc, import_wizard, importer.title and add_verse are called with
# known calls
# THEN: do_import should return None, and pyodbc, import_wizard, importer.title and add_verse are called
# with known calls
self.assertIsNone(return_value, 'do_import should return None when pyodbc raises an exception.')
mocked_pyodbc.connect.assert_called_with('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=import_source')
mocked_pyodbc.connect().cursor.assert_any_call()

View File

@ -116,28 +116,27 @@ class SongImportTestHelper(TestCase):
if song_copyright:
self.mocked_add_copyright.assert_called_with(song_copyright)
if ccli_number:
self.assertEquals(importer.ccli_number, ccli_number, 'ccli_number for %s should be %s'
% (source_file_name, ccli_number))
self.assertEquals(importer.ccli_number, ccli_number, 'ccli_number for %s should be %s' %
(source_file_name, ccli_number))
for verse_text, verse_tag in add_verse_calls:
self.mocked_add_verse.assert_any_call(verse_text, verse_tag)
if topics:
self.assertEquals(importer.topics, topics, 'topics for %s should be %s' % (source_file_name, topics))
if comments:
self.assertEquals(importer.comments, comments, 'comments for %s should be "%s"'
% (source_file_name, comments))
self.assertEquals(importer.comments, comments, 'comments for %s should be "%s"' %
(source_file_name, comments))
if song_book_name:
self.assertEquals(importer.song_book_name, song_book_name, 'song_book_name for %s should be "%s"'
% (source_file_name, song_book_name))
self.assertEquals(importer.song_book_name, song_book_name, 'song_book_name for %s should be "%s"' %
(source_file_name, song_book_name))
if song_number:
self.assertEquals(importer.song_number, song_number, 'song_number for %s should be %s'
% (source_file_name, song_number))
self.assertEquals(importer.song_number, song_number, 'song_number for %s should be %s' %
(source_file_name, song_number))
if verse_order_list:
self.assertEquals(importer.verse_order_list, [], 'verse_order_list for %s should be %s'
% (source_file_name, verse_order_list))
self.assertEquals(importer.verse_order_list, [], 'verse_order_list for %s should be %s' %
(source_file_name, verse_order_list))
self.mocked_finish.assert_called_with()
def _get_data(self, data, key):
if key in data:
return data[key]
return ''

View File

@ -95,4 +95,3 @@ class TestPluginManager(TestCase, TestMixin):
assert 'songusage' in plugin_names, 'There should be a "songusage" plugin.'
assert 'alerts' in plugin_names, 'There should be a "alerts" plugin.'
assert 'remotes' in plugin_names, 'There should be a "remotes" plugin.'

View File

@ -133,5 +133,3 @@ class TestSearchEdit(TestCase, TestMixin):
Just check if the resizeEvent() method is re-implemented.
"""
assert hasattr(self.search_edit, "resizeEvent"), "The search edit should re-implement the resizeEvent method."

View File

@ -85,4 +85,3 @@ class TestMainWindow(TestCase, TestMixin):
# THEN: The current widget should have been set.
self.main_window.media_tool_box.setCurrentIndex.assert_called_with(2)

View File

@ -90,9 +90,8 @@ class TestStartNoteDialog(TestCase, TestMixin):
with patch('PyQt4.QtGui.QDialog.exec_'):
self.form.exec_()
self.form.text_edit.setPlainText(text)
okWidget = self.form.button_box.button(self.form.button_box.Save)
QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
ok_widget = self.form.button_box.button(self.form.button_box.Save)
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
# THEN the following text is returned
self.assertEqual(self.form.text_edit.toPlainText(), text, 'The new text should be returned')

View File

@ -86,4 +86,3 @@ class TestUtils(TestCase, TestMixin):
# THEN the result is false
assert result is True, 'The file is not an image file so the test should return True'

View File

@ -97,4 +97,3 @@ class TestBibleHTTP(TestCase):
# THEN: We should get back a valid service item
assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'

View File

@ -115,4 +115,3 @@ class TestBibleManager(TestCase, TestMixin):
verses = self.manager.get_verse_count_by_book_ref_id('tests', 54, 3)
# THEN the chapter count should be returned
self.assertEqual(16, verses, '1 Timothy v3 should have 16 verses returned from the bible')

View File

@ -83,7 +83,7 @@ class TestBibleManager(TestCase, TestMixin):
# WHEN asking to parse the bible reference
results = parse_reference('1 Timothy 1', self.manager.db_cache['tests'], MagicMock(), 54)
# THEN a verse array should be returned
self.assertEquals([(54, 1, 1, -1)], results , "The bible verses should matches the expected results")
self.assertEquals([(54, 1, 1, -1)], results, "The bible verses should matches the expected results")
def parse_reference_two_test(self):
"""
@ -93,7 +93,7 @@ class TestBibleManager(TestCase, TestMixin):
# WHEN asking to parse the bible reference
results = parse_reference('1 Timothy 1:1-2', self.manager.db_cache['tests'], MagicMock(), 54)
# THEN a verse array should be returned
self.assertEquals([(54, 1, 1, 2)], results , "The bible verses should matches the expected results")
self.assertEquals([(54, 1, 1, 2)], results, "The bible verses should matches the expected results")
def parse_reference_three_test(self):
"""
@ -103,4 +103,5 @@ class TestBibleManager(TestCase, TestMixin):
# WHEN asking to parse the bible reference
results = parse_reference('1 Timothy 1:1-2:1', self.manager.db_cache['tests'], MagicMock(), 54)
# THEN a verse array should be returned
self.assertEquals([(54,1,1,-1),(54,2,1,1)], results , "The bible verses should matches the expected results")
self.assertEquals([(54, 1, 1, -1), (54, 2, 1, 1)], results, "The bible verses should matches the expected "
"results")

View File

@ -26,4 +26,3 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################

View File

@ -25,4 +25,4 @@
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
###############################################################################

View File

@ -88,7 +88,6 @@ class TestEditCustomForm(TestCase, TestMixin):
self.assertEqual(self.form.title_edit.text(), '', 'The title edit should be empty')
self.assertEqual(self.form.credit_edit.text(), '', 'The credit edit should be empty')
def on_add_button_clicked_test(self):
"""
Test the on_add_button_clicked_test method / add_button button.

View File

@ -92,4 +92,3 @@ class TestEditCustomSlideForm(TestCase, TestMixin):
# THEN: The dialog should have focus.
mocked_set_focus.assert_called_with()

View File

@ -25,4 +25,4 @@
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
###############################################################################

View File

@ -145,4 +145,3 @@ class TestAuthorsForm(TestCase, TestMixin):
# THEN: The display_name_edit should have the correct value
self.assertEqual(self.form.display_edit.text(), display_name, 'The display name should be set correctly')

View File

@ -120,4 +120,3 @@ class TestEditVerseForm(TestCase, TestMixin):
# THEN: The verse text edit should have a Chorus:1 in it
self.assertIn('---[Chorus:1]---', self.form.verse_text_edit.toPlainText(),
'The verse text edit should have a "Chorus 1" marker')