functional more bits

This commit is contained in:
Tim Bentley 2017-12-22 22:20:04 +00:00
parent e9b4d2d7be
commit aee4f76093
24 changed files with 178 additions and 187 deletions

View File

@ -51,7 +51,7 @@ class TestAlertManager(TestCase):
alert_manager.alert_text('')
# THEN: the display should not have been triggered
self.assertFalse(alert_manager.display_alert.called, 'The Alert should not have been called')
assert alert_manager.display_alert.called is False, 'The Alert should not have been called'
def test_trigger_message_text(self):
"""
@ -65,7 +65,7 @@ class TestAlertManager(TestCase):
alert_manager.alert_text(['This is a string'])
# THEN: the display should have been triggered
self.assertTrue(alert_manager.display_alert.called, 'The Alert should have been called')
assert alert_manager.display_alert.called is True, 'The Alert should have been called'
def test_line_break_message_text(self):
"""

View File

@ -1375,7 +1375,7 @@ class TestMediaItem(TestCase, TestMixin):
assert self.media_item.search_results == [mocked_verse_1]
assert self.media_item.second_search_results == [mocked_verse_1a]
assert self.mocked_log.debug.call_count == 2
assertTrue(self.mocked_main_window.information_message.called)
assert self.mocked_main_window.information_message.called is True
mocked_display_results.assert_called_once_with()
def test_on_search_edit_text_changed_search_while_typing_disabled(self):
@ -1391,7 +1391,7 @@ class TestMediaItem(TestCase, TestMixin):
self.media_item.on_search_edit_text_changed()
# THEN: The method should not have checked if the timer is active
assertFalse(self.media_item.search_timer.isActive.called)
assert self.media_item.search_timer.isActive.called is False
def test_on_search_edit_text_changed_search_while_typing_enabled(self):
"""
@ -1441,7 +1441,7 @@ class TestMediaItem(TestCase, TestMixin):
self.media_item.display_results()
# THEN: No items should be added to the list
assertFalse(self.media_item.list_view.addItem.called)
assert self.media_item.list_view.addItem.called is False
def test_display_results_results(self):
"""

View File

@ -164,8 +164,7 @@ class TestImageMediaItem(TestCase):
self.media_item.save_new_images_list(image_list, reload_list=False)
# THEN: load_full_list() should not have been called
self.assertEquals(self.media_item.manager.save_object.call_count, 2,
'load_full_list() should have been called only once')
assert self.media_item.manager.save_object.call_count == 2, 'load_full_list() should have been called only once'
def test_on_reset_click(self):
"""
@ -277,7 +276,7 @@ class TestImageMediaItem(TestCase):
# THEN: A QTreeWidgetItem should be created with the above model object as it's data
assert isinstance(item, QtWidgets.QTreeWidgetItem)
self.assertEqual('test_file_1.jpg', item.text(0))
assert 'test_file_1.jpg' == item.text(0)
item_data = item.data(0, QtCore.Qt.UserRole)
assert isinstance(item_data, ImageFilenames)
assert 1 == item_data.id

View File

@ -71,7 +71,7 @@ class MediaPluginTest(TestCase, TestMixin):
result = process_check_binary('MediaInfo')
# THEN: The the result should be True
self.assertTrue(result, 'Mediainfo should have been found')
assert result is True, 'Mediainfo should have been found'
@patch('openlp.plugins.media.mediaplugin.check_binary_exists')
def test_process_check_binary_fail(self, mocked_checked_binary_exists):
@ -84,4 +84,4 @@ class MediaPluginTest(TestCase, TestMixin):
result = process_check_binary("MediaInfo1")
# THEN: The the result should be True
self.assertFalse(result, "Mediainfo should not have been found")
assert result is False, "Mediainfo should not have been found"

View File

@ -81,11 +81,11 @@ class TestMediaItem(TestCase, TestMixin):
self.media_item.build_file_mask_string()
# THEN: The file mask should be generated correctly
assertIn('*.odp', self.media_item.on_new_file_masks, 'The file mask should contain the odp extension')
assertIn('*.ppt', self.media_item.on_new_file_masks, 'The file mask should contain the ppt extension')
assertIn('*.pdf', self.media_item.on_new_file_masks, 'The file mask should contain the pdf extension')
assertIn('*.xps', self.media_item.on_new_file_masks, 'The file mask should contain the xps extension')
assertIn('*.oxps', self.media_item.on_new_file_masks, 'The file mask should contain the oxps extension')
assert '*.odp' in self.media_item.on_new_file_masks, 'The file mask should contain the odp extension'
assert '*.ppt' in self.media_item.on_new_file_masks, 'The file mask should contain the ppt extension'
assert '*.pdf' in self.media_item.on_new_file_masks, 'The file mask should contain the pdf extension'
assert '*.xps' in self.media_item.on_new_file_masks, 'The file mask should contain the xps extension'
assert '*.oxps' in self.media_item.on_new_file_masks, 'The file mask should contain the oxps extension'
def test_clean_up_thumbnails(self):
"""

View File

@ -73,7 +73,7 @@ class TestMessageListener(TestCase, TestMixin):
ml.startup([mock_item, False, False, False])
# THEN: The controllers will be setup.
self.assertTrue(len(controllers), 'We have loaded a controller')
assert len(controllers) > 0, 'We have loaded a controller'
@patch('openlp.plugins.presentations.lib.mediaitem.MessageListener._setup')
def test_start_presentation_with_no_player(self, media_mock):
@ -105,7 +105,7 @@ class TestMessageListener(TestCase, TestMixin):
ml.startup([mock_item, False, False, False])
# THEN: The controllers will be setup.
self.assertTrue(len(controllers), 'We have loaded a controller')
assert len(controllers) > 0, 'We have loaded a controller'
@patch('openlp.plugins.presentations.lib.mediaitem.MessageListener._setup')
def test_start_pdf_presentation(self, media_mock):
@ -125,7 +125,7 @@ class TestMessageListener(TestCase, TestMixin):
ml.startup([mock_item, False, False, False])
# THEN: The handler should be set to None
self.assertIsNone(ml.handler, 'The handler should be None')
assert ml.handler is None, 'The handler should be None'
class TestController(TestCase, TestMixin):

View File

@ -131,7 +131,7 @@ class TestPdfController(TestCase, TestMixin):
loaded = document.load_presentation()
# THEN: The load should succeed and pictures should be created and have been scales to fit the screen
self.assertTrue(loaded, 'The loading of the PDF should succeed.')
assert loaded is True, 'The loading of the PDF should succeed.'
image = QtGui.QImage(os.path.join(str(self.temp_folder_path), 'pdf_test1.pdf', 'mainslide001.png'))
# Based on the converter used the resolution will differ a bit
if controller.gsbin:

View File

@ -249,7 +249,7 @@ class TestPowerpointDocument(TestCase, TestMixin):
doc.goto_slide(1)
# THEN: next_step() should be call to try to advance to the next effect.
assertTrue(doc.next_step.called, 'next_step() should have been called!')
assert doc.next_step.called, 'next_step() should have been called!' is True
def test_blank_screen(self):
"""

View File

@ -164,7 +164,7 @@ class TestPptviewDocument(TestCase):
result = instance.load_presentation()
# THEN: The temp folder should be created and PptviewDocument.load_presentation should return False
self.assertFalse(result)
assert result is False
def test_create_titles_and_notes(self):
"""

View File

@ -151,7 +151,7 @@ class TestPresentationController(TestCase):
result_titles, result_notes = self.document.get_titles_and_notes()
# THEN: it should return two empty lists
assertIs(type(result_titles), list, 'result_titles should be a list')
assert type(result_titles) is list, 'result_titles should be a list'
class TestPresentationDocument(TestCase):
@ -226,4 +226,4 @@ class TestPresentationDocument(TestCase):
result = instance.load_presentation()
# THEN: load_presentation should return false
assertFalse(result, "PresentationDocument.load_presentation should return false.")
assert result is False, "PresentationDocument.load_presentation should return false."

View File

@ -66,10 +66,10 @@ class TestDB(TestCase):
song.add_author(author)
# THEN: The author should have been added with author_type=None
self.assertEqual(1, len(song.authors_songs))
self.assertEqual("Max", song.authors_songs[0].author.first_name)
self.assertEqual("Mustermann", song.authors_songs[0].author.last_name)
self.assertIsNone(song.authors_songs[0].author_type)
assert 1 == len(song.authors_songs)
assert "Max" == song.authors_songs[0].author.first_name
assert "Mustermann" == song.authors_songs[0].author.last_name
assert song.authors_songs[0].author_type is None
def test_add_author_with_type(self):
"""
@ -86,10 +86,10 @@ class TestDB(TestCase):
song.add_author(author, AuthorType.Words)
# THEN: The author should have been added with author_type=None
self.assertEqual(1, len(song.authors_songs))
self.assertEqual("Max", song.authors_songs[0].author.first_name)
self.assertEqual("Mustermann", song.authors_songs[0].author.last_name)
self.assertEqual(AuthorType.Words, song.authors_songs[0].author_type)
assert 1 == len(song.authors_songs)
assert "Max" == song.authors_songs[0].author.first_name
assert "Mustermann" == song.authors_songs[0].author.last_name
assert AuthorType.Words == song.authors_songs[0].author_type
def test_remove_author(self):
"""
@ -105,7 +105,7 @@ class TestDB(TestCase):
song.remove_author(author)
# THEN: It should have been removed
self.assertEqual(0, len(song.authors_songs))
assert 0 == len(song.authors_songs)
def test_remove_author_with_type(self):
"""
@ -122,8 +122,8 @@ class TestDB(TestCase):
song.remove_author(author, AuthorType.Translation)
# THEN: It should have been removed and the other author should still be there
self.assertEqual(1, len(song.authors_songs))
self.assertEqual(None, song.authors_songs[0].author_type)
assert 1 == len(song.authors_songs)
assert song.authors_songs[0].author_type is None
def test_get_author_type_from_translated_text(self):
"""
@ -136,7 +136,7 @@ class TestDB(TestCase):
author_type = AuthorType.from_translated_text(author_type_name)
# THEN: The type should be correct
self.assertEqual(author_type, AuthorType.Words)
assert author_type == AuthorType.Words
def test_author_get_display_name(self):
"""
@ -150,7 +150,7 @@ class TestDB(TestCase):
display_name = author.get_display_name()
# THEN: It should return only the name
self.assertEqual("John Doe", display_name)
assert "John Doe" == display_name
def test_author_get_display_name_with_type_words(self):
"""
@ -164,7 +164,7 @@ class TestDB(TestCase):
display_name = author.get_display_name(AuthorType.Words)
# THEN: It should return the name with the type in brackets
self.assertEqual("John Doe (Words)", display_name)
assert "John Doe (Words)" == display_name
def test_author_get_display_name_with_type_translation(self):
"""
@ -178,7 +178,7 @@ class TestDB(TestCase):
display_name = author.get_display_name(AuthorType.Translation)
# THEN: It should return the name with the type in brackets
self.assertEqual("John Doe (Translation)", display_name)
assert "John Doe (Translation)" == display_name
def test_add_songbooks(self):
"""
@ -195,7 +195,7 @@ class TestDB(TestCase):
song.add_songbook_entry(songbook, "550A")
# THEN: The song should have two songbook entries
self.assertEqual(len(song.songbook_entries), 2, 'There should be two Songbook entries.')
assert len(song.songbook_entries) == 2, 'There should be two Songbook entries.'
def test_upgrade_old_song_db(self):
"""
@ -211,8 +211,7 @@ class TestDB(TestCase):
updated_to_version, latest_version = upgrade_db(db_url, upgrade)
# THEN: the song db should have been upgraded to the latest version
self.assertEqual(updated_to_version, latest_version,
'The song DB should have been upgrade to the latest version')
assert updated_to_version == latest_version, 'The song DB should have been upgrade to the latest version'
def test_upgrade_invalid_song_db(self):
"""
@ -228,5 +227,4 @@ class TestDB(TestCase):
updated_to_version, latest_version = upgrade_db(db_url, upgrade)
# THEN: the song db should have been upgraded to the latest version without errors
self.assertEqual(updated_to_version, latest_version,
'The song DB should have been upgrade to the latest version')
assert updated_to_version == latest_version, 'The song DB should have been upgrade to the latest version'

View File

@ -64,7 +64,7 @@ class TestEditSongForm(TestCase, TestMixin):
valid = self.edit_song_form._validate_tags(tags)
# THEN they should be valid
self.assertTrue(valid, "The tags list should be valid")
assert valid is True, "The tags list should be valid"
def test_validate_nonmatching_tags(self):
# Given a set of tags
@ -74,7 +74,7 @@ class TestEditSongForm(TestCase, TestMixin):
valid = self.edit_song_form._validate_tags(tags)
# THEN they should be valid
self.assertTrue(valid, "The tags list should be valid")
assert valid is True, "The tags list should be valid"
@patch('openlp.plugins.songs.forms.editsongform.set_case_insensitive_completer')
def test_load_objects(self, mocked_set_case_insensitive_completer):

View File

@ -165,11 +165,10 @@ class TestEasyWorshipSongImport(TestCase):
field_desc_entry = FieldDescEntry(name, field_type, size)
# THEN:
self.assertIsNotNone(field_desc_entry, 'Import should not be none')
self.assertEqual(field_desc_entry.name, name, 'FieldDescEntry.name should be the same as the name argument')
self.assertEqual(field_desc_entry.field_type, field_type,
'FieldDescEntry.type should be the same as the type argument')
self.assertEqual(field_desc_entry.size, size, 'FieldDescEntry.size should be the same as the size argument')
assert field_desc_entry is not None, 'Import should not be none'
assert field_desc_entry.name, name == 'FieldDescEntry.name should be the same as the name argument'
assert field_desc_entry.field_type == field_type, 'FieldDescEntry.type should be the same as the type argument'
assert field_desc_entry.size == size, 'FieldDescEntry.size should be the same as the size argument'
def test_create_importer(self):
"""
@ -183,7 +182,7 @@ class TestEasyWorshipSongImport(TestCase):
importer = EasyWorshipSongImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
assert importer is not None, 'Import should not be none'
def test_find_field_exists(self):
"""
@ -201,7 +200,7 @@ class TestEasyWorshipSongImport(TestCase):
for field_name in existing_fields:
# THEN: The item corresponding the index returned should have the same name attribute
self.assertEqual(importer.field_descriptions[importer.db_find_field(field_name)].name, field_name)
assert importer.field_descriptions[importer.db_find_field(field_name)].name == field_name
def test_find_non_existing_field(self):
"""
@ -236,7 +235,7 @@ class TestEasyWorshipSongImport(TestCase):
# THEN: db_set_record_struct should return None and Struct should be called with a value representing
# the list of field descriptions
self.assertIsNone(return_value, 'db_set_record_struct should return None')
assert return_value is None, 'db_set_record_struct should return None'
mocked_struct.Struct.assert_called_with('>50sHIB250s250s10sQ')
@patch('openlp.plugins.songs.lib.importers.easyworship.SongImport')
@ -257,9 +256,8 @@ class TestEasyWorshipSongImport(TestCase):
return_value = importer.db_get_field(field_index)
# THEN: db_get_field should return the known results
self.assertEqual(return_value, result,
'db_get_field should return "%s" when called with "%s"' %
(result, TEST_FIELDS[field_index]))
assert return_value == result, 'db_get_field should return "%s" when called with "%s"' % \
(result, TEST_FIELDS[field_index])
@patch('openlp.plugins.songs.lib.importers.easyworship.SongImport')
def test_get_memo_field(self, MockSongImport):
@ -285,7 +283,7 @@ class TestEasyWorshipSongImport(TestCase):
# THEN: db_get_field should return the appropriate value with the appropriate mocked objects being
# called
self.assertEqual(importer.db_get_field(field_index), get_field_result)
assert importer.db_get_field(field_index) == get_field_result
for call in get_field_read_calls:
mocked_memo_file.read.assert_any_call(call)
for call in get_field_seek_calls:
@ -330,7 +328,7 @@ class TestEasyWorshipSongImport(TestCase):
mocked_stat.return_value.st_size = 0x7FF
# THEN: do_import should return None having called Path.stat()
self.assertIsNone(importer.do_import(), 'do_import should return None when db_size is less than 0x800')
assert importer.do_import() is None, 'do_import should return None when db_size is less than 0x800'
mocked_stat.assert_called_once_with()
@patch('openlp.plugins.songs.lib.importers.easyworship.SongImport')
@ -353,11 +351,10 @@ class TestEasyWorshipSongImport(TestCase):
# THEN: do_import should return None having called closed the open files db and memo files.
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')
assert importer.do_import() is None, 'do_import should return None when db_size is less than 0x800'
assert mocked_open().close.call_count == 2, '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.')
assert mocked_open().seek.called is False, 'db_file.seek should not have been called.'
@patch('openlp.plugins.songs.lib.importers.easyworship.SongImport')
@patch('openlp.plugins.songs.lib.importers.easyworship.Path.is_file', return_value=True)
@ -383,7 +380,7 @@ class TestEasyWorshipSongImport(TestCase):
mocked_retrieve_windows_encoding.return_value = False
# THEN: do_import should return None having called retrieve_windows_encoding with the correct encoding.
self.assertIsNone(importer.do_import(), 'do_import should return None when db_size is less than 0x800')
assert importer.do_import() is None, 'do_import should return None when db_size is less than 0x800'
mocked_retrieve_windows_encoding.assert_any_call(encoding)
def test_db_file_import(self):
@ -425,7 +422,7 @@ class TestEasyWorshipSongImport(TestCase):
# THEN: do_import should return none, the song data should be as expected, and finish should have been
# called.
self.assertIsNone(import_result, 'do_import should return None when it has completed')
assert import_result is None, 'do_import should return None when it has completed'
for song_data in SONG_TEST_DATA:
title = song_data['title']
author_calls = song_data['authors']
@ -433,19 +430,18 @@ class TestEasyWorshipSongImport(TestCase):
ccli_number = song_data['ccli_number']
add_verse_calls = song_data['verses']
verse_order_list = song_data['verse_order_list']
self.assertIn(title, importer._title_assignment_list, 'title for %s should be "%s"' % (title, title))
assert title in importer._title_assignment_list, 'title for %s should be "%s"' % (title, title)
for author in author_calls:
mocked_add_author.assert_any_call(author)
if song_copyright:
self.assertEqual(importer.copyright, song_copyright)
assert importer.copyright == song_copyright
if ccli_number:
self.assertEqual(importer.ccli_number, ccli_number,
'ccli_number for %s should be %s' % (title, ccli_number))
assert importer.ccli_number == ccli_number, 'ccli_number for %s should be %s' % (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.assertEqual(importer.verse_order_list, verse_order_list,
'verse_order_list for %s should be %s' % (title, verse_order_list))
assert importer.verse_order_list == verse_order_list, \
'verse_order_list for %s should be %s' % (title, verse_order_list)
mocked_finish.assert_called_with()
@patch('openlp.plugins.songs.lib.importers.easyworship.SongImport')
@ -481,8 +477,8 @@ class TestEasyWorshipSongImport(TestCase):
# THEN: do_import should return none, the song data should be as expected, and finish should have been
# called.
title = EWS_SONG_TEST_DATA['title']
self.assertIsNone(import_result, 'do_import should return None when it has completed')
self.assertIn(title, importer._title_assignment_list, 'title for should be "%s"' % title)
assert import_result is None, 'do_import should return None when it has completed'
assert title in importer._title_assignment_list, 'title for should be "%s"' % title
mocked_add_author.assert_any_call(EWS_SONG_TEST_DATA['authors'][0])
for verse_text, verse_tag in EWS_SONG_TEST_DATA['verses']:
mocked_add_verse.assert_any_call(verse_text, verse_tag)
@ -505,4 +501,4 @@ class TestEasyWorshipSongImport(TestCase):
importer.set_song_import_object('Test Author', b'Det som var fr\x86n begynnelsen')
# THEN: The import should fail
self.assertEquals(importer.entry_error_log, 'Unexpected data formatting.', 'Import should fail')
assert importer.entry_error_log == 'Unexpected data formatting.', 'Import should fail'

View File

@ -106,7 +106,7 @@ class TestFoilPresenter(TestCase):
foil_presenter_instance = FoilPresenter(mocked_manager, mocked_song_import)
# THEN: The instance should not be None
self.assertIsNotNone(foil_presenter_instance, 'foil_presenter instance should not be none')
assert foil_presenter_instance is not None, 'foil_presenter instance should not be none'
def test_no_xml(self):
"""
@ -122,7 +122,7 @@ class TestFoilPresenter(TestCase):
result = foil_presenter_instance.xml_to_song(arg)
# Then: xml_to_song should return False
self.assertEqual(result, None, 'xml_to_song should return None when called with %s' % arg)
assert result is None, 'xml_to_song should return None when called with %s' % arg
def test_encoding_declaration_removal(self):
"""
@ -169,6 +169,6 @@ class TestFoilPresenter(TestCase):
result = foil_presenter_instance._process_lyrics(mock_foilpresenterfolie, mocked_song)
# THEN: _process_lyrics should return None and the song_import log_error method should have been called once
self.assertIsNone(result)
assert result is None
self.mocked_song_import.log_error.assert_called_once_with('Element Text', 'Translated String')
self.process_lyrics_patcher.start()

View File

@ -63,7 +63,7 @@ class TestLib(TestCase):
result = clean_string(dirty_string)
# THEN: The string should be cleaned up and lower-cased
self.assertEqual(result, 'aint gonna find you there ', 'The string should be cleaned up properly')
assert result == 'aint gonna find you there ', 'The string should be cleaned up properly'
def test_clean_title(self):
"""
@ -76,7 +76,7 @@ class TestLib(TestCase):
result = clean_title(dirty_string)
# THEN: The string should be cleaned up
self.assertEqual(result, 'This is a dirty string', 'The title should be cleaned up properly: "%s"' % result)
assert result == 'This is a dirty string', 'The title should be cleaned up properly: "%s"' % result
def test_songs_probably_equal_same_song(self):
"""
@ -275,7 +275,7 @@ class TestLib(TestCase):
new_chord = transpose_chord(chord, 1, 'english')
# THEN: The chord should be transposed up one note
self.assertEqual(new_chord, 'C#', 'The chord should be transposed up.')
assert new_chord == 'C#', 'The chord should be transposed up.'
def test_transpose_chord_up_adv(self):
"""
@ -288,7 +288,7 @@ class TestLib(TestCase):
new_chord = transpose_chord(chord, 1, 'english')
# THEN: The chord should be transposed up one note
self.assertEqual(new_chord, '(C#/E)', 'The chord should be transposed up.')
assert new_chord == '(C#/E)', 'The chord should be transposed up.'
def test_transpose_chord_down(self):
"""
@ -301,7 +301,7 @@ class TestLib(TestCase):
new_chord = transpose_chord(chord, -1, 'english')
# THEN: The chord should be transposed down one note
self.assertEqual(new_chord, 'B', 'The chord should be transposed down.')
assert new_chord == 'B', 'The chord should be transposed down.'
def test_transpose_chord_error(self):
"""
@ -314,8 +314,8 @@ class TestLib(TestCase):
# THEN: An exception should be raised
with self.assertRaises(ValueError) as err:
new_chord = transpose_chord(chord, -1, 'english')
self.assertEqual(err.exception.args[0], '\'T\' is not in list',
'ValueError exception should have been thrown for invalid chord')
assert err.exception.args[0] == '\'T\' is not in list', \
'ValueError exception should have been thrown for invalid chord'
@patch('openlp.plugins.songs.lib.transpose_verse')
@patch('openlp.plugins.songs.lib.Settings')
@ -361,13 +361,13 @@ class TestVerseType(TestCase):
result = VerseType.translated_tag('v')
# THEN: The result should be "V"
self.assertEqual(result, 'V', 'The result should be "V"')
assert result == 'V', 'The result should be "V"'
# WHEN: We run the translated_tag() method with a "chorus"
result = VerseType.translated_tag('c')
# THEN: The result should be "C"
self.assertEqual(result, 'C', 'The result should be "C"')
assert result == 'C', 'The result should be "C"'
def test_translated_invalid_tag(self):
"""
@ -381,7 +381,7 @@ class TestVerseType(TestCase):
result = VerseType.translated_tag('z')
# THEN: The result should be "O"
self.assertEqual(result, 'O', 'The result should be "O", but was "%s"' % result)
assert result == 'O', 'The result should be "O", but was "%s"' % result
def test_translated_invalid_tag_with_specified_default(self):
"""
@ -395,7 +395,7 @@ class TestVerseType(TestCase):
result = VerseType.translated_tag('q', VerseType.Bridge)
# THEN: The result should be "B"
self.assertEqual(result, 'B', 'The result should be "B", but was "%s"' % result)
assert result == 'B', 'The result should be "B", but was "%s"' % result
def test_translated_invalid_tag_with_invalid_default(self):
"""
@ -409,7 +409,7 @@ class TestVerseType(TestCase):
result = VerseType.translated_tag('q', 29)
# THEN: The result should be "O"
self.assertEqual(result, 'O', 'The result should be "O", but was "%s"' % result)
assert result == 'O', 'The result should be "O", but was "%s"' % result
def test_translated_name(self):
"""
@ -423,13 +423,13 @@ class TestVerseType(TestCase):
result = VerseType.translated_name('v')
# THEN: The result should be "Verse"
self.assertEqual(result, 'Verse', 'The result should be "Verse"')
assert result == 'Verse', 'The result should be "Verse"'
# WHEN: We run the translated_name() method with a "chorus"
result = VerseType.translated_name('c')
# THEN: The result should be "Chorus"
self.assertEqual(result, 'Chorus', 'The result should be "Chorus"')
assert result == 'Chorus', 'The result should be "Chorus"'
def test_translated_invalid_name(self):
"""
@ -443,7 +443,7 @@ class TestVerseType(TestCase):
result = VerseType.translated_name('z')
# THEN: The result should be "Other"
self.assertEqual(result, 'Other', 'The result should be "Other", but was "%s"' % result)
assert result == 'Other', 'The result should be "Other", but was "%s"' % result
def test_translated_invalid_name_with_specified_default(self):
"""
@ -457,7 +457,7 @@ class TestVerseType(TestCase):
result = VerseType.translated_name('q', VerseType.Bridge)
# THEN: The result should be "Bridge"
self.assertEqual(result, 'Bridge', 'The result should be "Bridge", but was "%s"' % result)
assert result == 'Bridge', 'The result should be "Bridge", but was "%s"' % result
def test_translated_invalid_name_with_invalid_default(self):
"""
@ -471,7 +471,7 @@ class TestVerseType(TestCase):
result = VerseType.translated_name('q', 29)
# THEN: The result should be "Other"
self.assertEqual(result, 'Other', 'The result should be "Other", but was "%s"' % result)
assert result == 'Other', 'The result should be "Other", but was "%s"' % result
def test_from_tag(self):
"""
@ -485,7 +485,7 @@ class TestVerseType(TestCase):
result = VerseType.from_tag('v')
# THEN: The result should be VerseType.Verse
self.assertEqual(result, VerseType.Verse, 'The result should be VerseType.Verse, but was "%s"' % result)
assert result == VerseType.Verse, 'The result should be VerseType.Verse, but was "%s"' % result
def test_from_tag_with_invalid_tag(self):
"""
@ -499,7 +499,7 @@ class TestVerseType(TestCase):
result = VerseType.from_tag('w')
# THEN: The result should be VerseType.Other
self.assertEqual(result, VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result)
assert result == VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result
def test_from_tag_with_specified_default(self):
"""
@ -513,7 +513,7 @@ class TestVerseType(TestCase):
result = VerseType.from_tag('x', VerseType.Chorus)
# THEN: The result should be VerseType.Chorus
self.assertEqual(result, VerseType.Chorus, 'The result should be VerseType.Chorus, but was "%s"' % result)
assert result == VerseType.Chorus, 'The result should be VerseType.Chorus, but was "%s"' % result
def test_from_tag_with_invalid_intdefault(self):
"""
@ -527,7 +527,7 @@ class TestVerseType(TestCase):
result = VerseType.from_tag('m', 29)
# THEN: The result should be VerseType.Other
self.assertEqual(result, VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result)
assert result == VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result
def test_from_tag_with_invalid_default(self):
"""
@ -541,7 +541,7 @@ class TestVerseType(TestCase):
result = VerseType.from_tag('@', 'asdf')
# THEN: The result should be VerseType.Other
self.assertEqual(result, VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result)
assert result == VerseType.Other, 'The result should be VerseType.Other, but was "%s"' % result
def test_from_tag_with_none_default(self):
"""
@ -555,7 +555,7 @@ class TestVerseType(TestCase):
result = VerseType.from_tag('m', None)
# THEN: The result should be None
self.assertIsNone(result, 'The result should be None, but was "%s"' % result)
assert result is None, 'The result should be None, but was "%s"' % result
@patch('openlp.plugins.songs.lib.VerseType.translated_tags', new_callable=PropertyMock, return_value=['x'])
def test_from_loose_input_with_invalid_input(self, mocked_translated_tags):
@ -567,7 +567,7 @@ class TestVerseType(TestCase):
result = VerseType.from_loose_input('m', None)
# THEN: The result should be None
self.assertIsNone(result, 'The result should be None, but was "%s"' % result)
assert result is None, 'The result should be None, but was "%s"' % result
@patch('openlp.plugins.songs.lib.VerseType.translated_tags', new_callable=PropertyMock, return_value=['x'])
def test_from_loose_input_with_valid_input(self, mocked_translated_tags):
@ -579,4 +579,4 @@ class TestVerseType(TestCase):
result = VerseType.from_loose_input('v')
# THEN: The result should be a Verse
self.assertEqual(result, VerseType.Verse, 'The result should be a verse, but was "%s"' % result)
assert result == VerseType.Verse, 'The result should be a verse, but was "%s"' % result

View File

@ -54,7 +54,7 @@ class TestMediaShoutImport(TestCase):
importer = MediaShoutImport(MagicMock(), file_path='mediashout.db')
# THEN: It should not be None
self.assertIsNotNone(importer)
assert importer is not None
@patch('openlp.plugins.songs.lib.importers.mediashout.pyodbc')
def test_do_import_fails_to_connect(self, mocked_pyodbc):
@ -112,7 +112,7 @@ class TestMediaShoutImport(TestCase):
call('SELECT Name FROM Groups INNER JOIN SongGroups ON SongGroups.GroupId = Groups.GroupId '
'WHERE SongGroups.Record = ?', 1.0)
]
self.assertEqual(expected_execute_calls, mocked_cursor.execute.call_args_list)
assert expected_execute_calls == mocked_cursor.execute.call_args_list
mocked_process_song.assert_called_once_with(song, [verse], [play_order], [theme, group])
@patch('openlp.plugins.songs.lib.importers.mediashout.pyodbc')
@ -172,16 +172,16 @@ class TestMediaShoutImport(TestCase):
# THEN: It should be added to the database
mocked_set_defaults.assert_called_once_with()
self.assertEqual('Amazing Grace', importer.title)
assert 'Amazing Grace' == importer.title
mocked_parse_author.assert_called_once_with('William Wilberforce')
mocked_add_copyright.assert_called_once_with('Public Domain')
self.assertEqual('Great old hymn', importer.comments)
self.assertEqual(['Grace', 'Hymns'], importer.topics)
self.assertEqual('Hymns', importer.song_book_name)
self.assertEqual('', importer.song_number)
assert 'Great old hymn' == importer.comments
assert ['Grace', 'Hymns'] == importer.topics
assert 'Hymns' == importer.song_book_name
assert '' == importer.song_number
mocked_add_verse.assert_called_once_with(
'Amazing grace, how sweet the sound\nThat saved a wretch like me', 'V1')
self.assertEqual(['V1'], importer.verse_order_list)
assert ['V1'] == importer.verse_order_list
mocked_finish.assert_called_once_with()
def test_process_song_with_song_number(self):
@ -214,14 +214,14 @@ class TestMediaShoutImport(TestCase):
# THEN: It should be added to the database
mocked_set_defaults.assert_called_once_with()
self.assertEqual('Amazing Grace', importer.title)
assert 'Amazing Grace' == importer.title
mocked_parse_author.assert_called_once_with('William Wilberforce')
mocked_add_copyright.assert_called_once_with('Public Domain')
self.assertEqual('Great old hymn', importer.comments)
self.assertEqual(['Grace', 'Hymns'], importer.topics)
self.assertEqual('Hymns', importer.song_book_name)
self.assertEqual('2', importer.song_number)
assert 'Great old hymn' == importer.comments
assert ['Grace', 'Hymns'] == importer.topics
assert 'Hymns' == importer.song_book_name
assert '2' == importer.song_number
mocked_add_verse.assert_called_once_with(
'Amazing grace, how sweet the sound\nThat saved a wretch like me', 'V1')
self.assertEqual(['V1'], importer.verse_order_list)
assert ['V1'], importer.verse_order_list
mocked_finish.assert_called_once_with()

View File

@ -51,7 +51,7 @@ class TestOpenLPImport(TestCase):
importer = OpenLPSongImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
assert importer is not None, 'Import should not be none'
def test_invalid_import_source(self):
"""
@ -70,6 +70,6 @@ class TestOpenLPImport(TestCase):
importer.import_source = source
# THEN: do_import should return none and the progress bar maximum should not be set.
self.assertIsNone(importer.do_import(), 'do_import should return None when import_source is not a list')
self.assertEqual(mocked_import_wizard.progress_bar.setMaximum.called, False,
'setMaximum on import_wizard.progress_bar should not have been called')
assert importer.do_import() is None, 'do_import should return None when import_source is not a list'
assert mocked_import_wizard.progress_bar.setMaximum.called == False, \
'setMaximum on import_wizard.progress_bar should not have been called'

View File

@ -134,7 +134,7 @@ class TestOpenLyricsImport(TestCase, TestMixin):
importer.do_import()
# THEN: The xml_to_song() method should have been called
self.assertTrue(importer.open_lyrics.xml_to_song.called)
assert importer.open_lyrics.xml_to_song.called is True
def test_process_formatting_tags(self):
"""
@ -173,8 +173,8 @@ class TestOpenLyricsImport(TestCase, TestMixin):
ol._process_authors(properties_xml, mocked_song)
# THEN: add_author should have been called twice
self.assertEquals(mocked_song.method_calls[0][1][1], 'words+music')
self.assertEquals(mocked_song.method_calls[1][1][1], 'words')
assert mocked_song.method_calls[0][1][1] == 'words+music'
assert mocked_song.method_calls[1][1][1] == 'words'
def test_process_songbooks(self):
"""
@ -192,5 +192,5 @@ class TestOpenLyricsImport(TestCase, TestMixin):
ol._process_songbooks(properties_xml, mocked_song)
# THEN: add_songbook_entry should have been called twice
self.assertEquals(mocked_song.method_calls[0][1][1], '48')
self.assertEquals(mocked_song.method_calls[1][1][1], '445 A')
assert mocked_song.method_calls[0][1][1] == '48'
assert mocked_song.method_calls[1][1][1] == '445 A'

View File

@ -87,7 +87,7 @@ class TestOpenSongImport(TestCase):
importer = OpenSongImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
assert importer is not None, 'Import should not be none'
def test_invalid_import_source(self):
"""

View File

@ -99,7 +99,7 @@ class TestSongBeamerImport(TestCase):
importer = SongBeamerImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
assert importer is not None, 'Import should not be none'
def test_invalid_import_source(self):
"""
@ -115,10 +115,10 @@ class TestSongBeamerImport(TestCase):
self.importer.import_source = source
# THEN: do_import should return none and the progress bar maximum should not be set.
self.assertIsNone(self.importer.do_import(),
'do_import should return None when import_source is not a list')
self.assertEqual(mocked_import_wizard.progress_bar.setMaximum.called, False,
'setMaxium on import_wizard.progress_bar should not have been called')
assert self.importer.do_import() is None, \
'do_import should return None when import_source is not a list'
assert mocked_import_wizard.progress_bar.setMaximum.called is False, \
'setMaxium on import_wizard.progress_bar should not have been called'
def test_valid_import_source(self):
"""
@ -134,8 +134,8 @@ 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(self.importer.do_import(),
'do_import should return None when import_source is a list and stop_import_flag is True')
assert self.importer.do_import() is None, \
'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(self.importer.import_source))
def test_check_verse_marks(self):
@ -149,8 +149,8 @@ class TestSongBeamerImport(TestCase):
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back true and c as self.importer.current_verse_type
self.assertTrue(result, 'Versemark for <Refrain> should be found, value true')
self.assertEqual(self.importer.current_verse_type, 'c', '<Refrain> should be interpreted as <c>')
.assert result is True, 'Versemark for <Refrain> should be found, value true'
assert self.importer.current_verse_type == 'c', '<Refrain> should be interpreted as <c>'
# GIVEN: line with unnumbered verse-type and trailing space
line = 'ReFrain '
@ -158,8 +158,8 @@ class TestSongBeamerImport(TestCase):
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back true and c as self.importer.current_verse_type
self.assertTrue(result, 'Versemark for <ReFrain > should be found, value true')
self.assertEqual(self.importer.current_verse_type, 'c', '<ReFrain > should be interpreted as <c>')
assert result is True, 'Versemark for <ReFrain > should be found, value true'
assert self.importer.current_verse_type == 'c', '<ReFrain > should be interpreted as <c>'
# GIVEN: line with numbered verse-type
line = 'VersE 1'
@ -167,8 +167,8 @@ class TestSongBeamerImport(TestCase):
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back true and v1 as self.importer.current_verse_type
self.assertTrue(result, 'Versemark for <VersE 1> should be found, value true')
self.assertEqual(self.importer.current_verse_type, 'v1', u'<VersE 1> should be interpreted as <v1>')
assert result is True, 'Versemark for <VersE 1> should be found, value true'
assert self.importer.current_verse_type == 'v1', u'<VersE 1> should be interpreted as <v1>'
# GIVEN: line with special unnumbered verse-mark (used in Songbeamer to allow usage of non-supported tags)
line = '$$M=special'
@ -176,8 +176,8 @@ class TestSongBeamerImport(TestCase):
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back true and o as self.importer.current_verse_type
self.assertTrue(result, 'Versemark for <$$M=special> should be found, value true')
self.assertEqual(self.importer.current_verse_type, 'o', u'<$$M=special> should be interpreted as <o>')
assert result is True, 'Versemark for <$$M=special> should be found, value true'
assert self.importer.current_verse_type == 'o', u'<$$M=special> should be interpreted as <o>'
# GIVEN: line with song-text with 3 words
line = 'Jesus my saviour'
@ -185,9 +185,8 @@ class TestSongBeamerImport(TestCase):
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back false and none as self.importer.current_verse_type
self.assertFalse(result, 'No versemark for <Jesus my saviour> should be found, value false')
self.assertIsNone(self.importer.current_verse_type,
'<Jesus my saviour> should be interpreted as none versemark')
assert result is False, 'No versemark for <Jesus my saviour> should be found, value false'
assert self.importer.current_verse_type is None, '<Jesus my saviour> should be interpreted as none versemark'
# GIVEN: line with song-text with 2 words
line = 'Praise him'
@ -195,8 +194,8 @@ class TestSongBeamerImport(TestCase):
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back false and none as self.importer.current_verse_type
self.assertFalse(result, 'No versemark for <Praise him> should be found, value false')
self.assertIsNone(self.importer.current_verse_type, '<Praise him> should be interpreted as none versemark')
assert result is False, 'No versemark for <Praise him> should be found, value false'
assert self.importer.current_verse_type is None, '<Praise him> should be interpreted as none versemark'
# GIVEN: line with only a space (could occur, nothing regular)
line = ' '
@ -204,8 +203,8 @@ class TestSongBeamerImport(TestCase):
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back false and none as self.importer.current_verse_type
self.assertFalse(result, 'No versemark for < > should be found, value false')
self.assertIsNone(self.importer.current_verse_type, '< > should be interpreted as none versemark')
assert result is False, 'No versemark for < > should be found, value false'
assert self.importer.current_verse_type is None, '< > should be interpreted as none versemark'
# GIVEN: blank line (could occur, nothing regular)
line = ''
@ -213,8 +212,8 @@ class TestSongBeamerImport(TestCase):
# WHEN: line is being checked for verse marks
result = self.importer.check_verse_marks(line)
# THEN: we should get back false and none as self.importer.current_verse_type
self.assertFalse(result, 'No versemark for <> should be found, value false')
self.assertIsNone(self.importer.current_verse_type, '<> should be interpreted as none versemark')
assert result is False, 'No versemark for <> should be found, value false'
assert self.importer.current_verse_type is None, '<> should be interpreted as none versemark'
def test_verse_marks_defined_in_lowercase(self):
"""
@ -223,4 +222,4 @@ class TestSongBeamerImport(TestCase):
# GIVEN: SongBeamber MarkTypes
for tag in SongBeamerTypes.MarkTypes.keys():
# THEN: tag should be defined in lowercase
self.assertEquals(tag, tag.lower(), 'Tags should be defined in lowercase')
assert tag == tag.lower(), 'Tags should be defined in lowercase'

View File

@ -39,8 +39,8 @@ class TestSongFormat(TestCase):
# GIVEN: The SongFormat class
# WHEN: Retrieving the format list
# THEN: All SongFormats should be returned
self.assertEquals(len(SongFormat.get_format_list()), len(SongFormat.__attributes__),
"The returned SongFormats don't match the stored ones")
assert len(SongFormat.get_format_list()) == len(SongFormat.__attributes__), \
"The returned SongFormats don't match the stored ones"
def test_get_attributed_no_attributes(self):
"""
@ -50,8 +50,8 @@ class TestSongFormat(TestCase):
# WHEN: Retrieving all attributes of a SongFormat
for song_format in SongFormat.get_format_list():
# THEN: All attributes associated with the SongFormat should be returned
self.assertEquals(SongFormat.get(song_format), SongFormat.__attributes__[song_format],
"The returned attributes don't match the stored ones")
assert SongFormat.get(song_format) == SongFormat.__attributes__[song_format], \
"The returned attributes don't match the stored ones"
def test_get_attributed_single_attribute(self):
"""
@ -62,14 +62,14 @@ class TestSongFormat(TestCase):
# WHEN: Retrieving an attribute that overrides the default values
for attribute in SongFormat.get(song_format).keys():
# THEN: Return the attribute
self.assertEquals(SongFormat.get(song_format, attribute), SongFormat.get(song_format)[attribute],
"The returned attribute doesn't match the stored one")
assert SongFormat.get(song_format, attribute) == SongFormat.get(song_format)[attribute], \
"The returned attribute doesn't match the stored one"
# WHEN: Retrieving an attribute that was not overridden
for attribute in SongFormat.__defaults__.keys():
if attribute not in SongFormat.get(song_format).keys():
# THEN: Return the default value
self.assertEquals(SongFormat.get(song_format, attribute), SongFormat.__defaults__[attribute],
"The returned attribute does not match the default values stored")
assert SongFormat.get(song_format, attribute) == SongFormat.__defaults__[attribute], \
"The returned attribute does not match the default values stored"
def test_get_attributed_multiple_attributes(self):
"""
@ -79,9 +79,8 @@ class TestSongFormat(TestCase):
# WHEN: Retrieving multiple attributes at the same time
for song_format in SongFormat.get_format_list():
# THEN: Return all attributes that were specified
self.assertEquals(len(SongFormat.get(song_format, 'canDisable', 'availability')), 2,
"Did not return the correct number of attributes"
" when retrieving multiple attributes at once")
assert len(SongFormat.get(song_format, 'canDisable', 'availability')) == 2, \
"Did not return the correct number of attributes when retrieving multiple attributes at once"
def test_get_format_list_returns_ordered_list(self):
"""
@ -91,5 +90,5 @@ class TestSongFormat(TestCase):
# GIVEN: The SongFormat class
# WHEN: Retrieving all formats
# THEN: The returned list should be sorted according to the ordering defined in SongFormat
self.assertEquals(sorted(SongFormat.get_format_list()), SongFormat.get_format_list(),
"The list returned should be sorted according to the ordering in SongFormat")
assert sorted(SongFormat.get_format_list()) == SongFormat.get_format_list(), \
"The list returned should be sorted according to the ordering in SongFormat"

View File

@ -610,7 +610,7 @@ class TestSongSelectForm(TestCase, TestMixin):
'Your song has been imported, would you like to import more songs?',
defaultButton=QtWidgets.QMessageBox.Yes)
mocked_on_back_button_clicked.assert_called_with()
self.assertIsNone(ssform.song)
assert ssform.song is None
@patch('openlp.plugins.songs.forms.songselectform.QtWidgets.QMessageBox.question')
@patch('openlp.plugins.songs.forms.songselectform.translate')
@ -636,7 +636,7 @@ class TestSongSelectForm(TestCase, TestMixin):
'Your song has been imported, would you like to import more songs?',
defaultButton=QtWidgets.QMessageBox.Yes)
mocked_done.assert_called_with(QtWidgets.QDialog.Accepted)
self.assertIsNone(ssform.song)
assert ssform.song is None
def test_on_back_button_clicked(self):
"""
@ -764,8 +764,8 @@ class TestSongSelectForm(TestCase, TestMixin):
# THEN: The view button, search box and search button should be enabled
mocked_song_select_importer.stop.assert_called_with()
self.assertTrue(ssform.search_button.isEnabled())
self.assertTrue(ssform.search_combobox.isEnabled())
assert ssform.search_button.isEnabled() is True
assert ssform.search_combobox.isEnabled() is True
@patch('openlp.plugins.songs.forms.songselectform.Settings')
@patch('openlp.plugins.songs.forms.songselectform.QtCore.QThread')
@ -782,8 +782,8 @@ class TestSongSelectForm(TestCase, TestMixin):
ssform.on_search_button_clicked()
# THEN: The search box and search button should be disabled
self.assertFalse(ssform.search_button.isEnabled())
self.assertFalse(ssform.search_combobox.isEnabled())
assert ssform.search_button.isEnabled() is False
assert ssform.search_combobox.isEnabled() is False
def test_on_search_finished(self):
"""
@ -797,8 +797,8 @@ class TestSongSelectForm(TestCase, TestMixin):
ssform.on_search_finished()
# THEN: The search box and search button should be enabled
self.assertTrue(ssform.search_button.isEnabled())
self.assertTrue(ssform.search_combobox.isEnabled())
assert ssform.search_button.isEnabled() is True
assert ssform.search_combobox.isEnabled() is True
class TestSongSelectFileImport(SongImportTestHelper):
@ -834,8 +834,8 @@ class TestSearchWorker(TestCase, TestMixin):
worker = SearchWorker(importer, search_text)
# THEN: The correct values should be set
self.assertIs(importer, worker.importer, 'The importer should be the right object')
self.assertEqual(search_text, worker.search_text, 'The search text should be correct')
assert importer is worker.importer, 'The importer should be the right object'
assert search_text == worker.search_text, 'The search text should be correct'
def test_start(self):
"""

View File

@ -73,7 +73,7 @@ class TestSongShowPlusImport(TestCase):
importer = SongShowPlusImport(mocked_manager, file_paths=[])
# THEN: The importer object should not be None
self.assertIsNotNone(importer, 'Import should not be none')
assert importer is not None, 'Import should not be none'
def test_invalid_import_source(self):
"""
@ -92,9 +92,9 @@ class TestSongShowPlusImport(TestCase):
importer.import_source = source
# THEN: do_import should return none and the progress bar maximum should not be set.
self.assertIsNone(importer.do_import(), 'do_import should return None when import_source is not a list')
self.assertEqual(mocked_import_wizard.progress_bar.setMaximum.called, False,
'setMaximum on import_wizard.progress_bar should not have been called')
assert importer.do_import() is None, 'do_import should return None when import_source is not a list'
assert mocked_import_wizard.progress_bar.setMaximum.called is False, \
'setMaximum on import_wizard.progress_bar should not have been called'
def test_valid_import_source(self):
"""
@ -113,8 +113,8 @@ class TestSongShowPlusImport(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')
assert importer.do_import() is None, \
'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 test_to_openlp_verse_tag(self):
@ -141,9 +141,9 @@ class TestSongShowPlusImport(TestCase):
# THEN: The returned value should should correlate with the input arguments
for original_tag, openlp_tag in test_values:
self.assertEqual(importer.to_openlp_verse_tag(original_tag), openlp_tag,
'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' %
(openlp_tag, original_tag))
assert importer.to_openlp_verse_tag(original_tag) == openlp_tag, \
'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' % \
(openlp_tag, original_tag)
def test_to_openlp_verse_tag_verse_order(self):
"""
@ -170,6 +170,6 @@ class TestSongShowPlusImport(TestCase):
# THEN: The returned value should should correlate with the input arguments
for original_tag, openlp_tag in test_values:
self.assertEqual(importer.to_openlp_verse_tag(original_tag, ignore_unique=True), openlp_tag,
'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' %
(openlp_tag, original_tag))
assert importer.to_openlp_verse_tag(original_tag, ignore_unique=True) == openlp_tag, \
'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' % \
(openlp_tag, original_tag)

View File

@ -80,7 +80,7 @@ class TestSongUsage(TestCase):
ret = song_usage.check_pre_conditions()
# THEN: It should return True
self.assertTrue(ret)
assert ret is True
@patch('openlp.plugins.songusage.songusageplugin.Manager')
def test_toggle_song_usage_state(self, MockedManager):
@ -96,4 +96,4 @@ class TestSongUsage(TestCase):
song_usage.toggle_song_usage_state()
# THEN: song_usage_state should have been toogled
self.assertFalse(song_usage.song_usage_active)
assert song_usage.song_usage_active is False