forked from openlp/openlp
almost finished
This commit is contained in:
parent
17b62ee6c9
commit
6729e78231
@ -141,7 +141,7 @@ class TestCategoryActionList(TestCase):
|
|||||||
assert self.action1 not in self.list
|
assert self.action1 not in self.list
|
||||||
|
|
||||||
# THEN: Check if an exception is raised when trying to remove a not present action.
|
# THEN: Check if an exception is raised when trying to remove a not present action.
|
||||||
self.assertRaises(ValueError, self.list.remove, self.action2)
|
assertRaises(ValueError, self.list.remove, self.action2)
|
||||||
|
|
||||||
|
|
||||||
class TestActionList(TestCase, TestMixin):
|
class TestActionList(TestCase, TestMixin):
|
||||||
|
@ -183,7 +183,7 @@ class TestInit(TestCase, TestMixin):
|
|||||||
# WHEN: Calling get_uno_command
|
# WHEN: Calling get_uno_command
|
||||||
|
|
||||||
# THEN: a FileNotFoundError exception should be raised
|
# THEN: a FileNotFoundError exception should be raised
|
||||||
self.assertRaises(FileNotFoundError, get_uno_command)
|
assertRaises(FileNotFoundError, get_uno_command)
|
||||||
|
|
||||||
def test_get_uno_command_connection_type(self):
|
def test_get_uno_command_connection_type(self):
|
||||||
"""
|
"""
|
||||||
|
@ -72,13 +72,13 @@ class TestImageManager(TestCase, TestMixin):
|
|||||||
image = self.image_manager.get_image(full_path, 'church.jpg')
|
image = self.image_manager.get_image(full_path, 'church.jpg')
|
||||||
|
|
||||||
# THEN returned record is a type of image
|
# THEN returned record is a type of image
|
||||||
self.assertEqual(isinstance(image, QtGui.QImage), True, 'The returned object should be a QImage')
|
assert isinstance(image, QtGui.QImage), 'The returned object should be a QImage'
|
||||||
|
|
||||||
# WHEN: The image bytes are requested.
|
# WHEN: The image bytes are requested.
|
||||||
byte_array = self.image_manager.get_image_bytes(full_path, 'church.jpg')
|
byte_array = self.image_manager.get_image_bytes(full_path, 'church.jpg')
|
||||||
|
|
||||||
# THEN: Type should be a str.
|
# THEN: Type should be a str.
|
||||||
self.assertEqual(isinstance(byte_array, str), True, 'The returned object should be a str')
|
assert isinstance(byte_array, str), 'The returned object should be a str'
|
||||||
|
|
||||||
# WHEN the image is retrieved has not been loaded
|
# WHEN the image is retrieved has not been loaded
|
||||||
# THEN a KeyError is thrown
|
# THEN a KeyError is thrown
|
||||||
@ -104,14 +104,14 @@ class TestImageManager(TestCase, TestMixin):
|
|||||||
self.image_manager.add_image(full_path, 'church.jpg', None, 100, 100)
|
self.image_manager.add_image(full_path, 'church.jpg', None, 100, 100)
|
||||||
|
|
||||||
# THEN: the cache should contain two pictures
|
# THEN: the cache should contain two pictures
|
||||||
self.assertEqual(len(self.image_manager._cache), 2,
|
assert len(self.image_manager._cache) == 2, \
|
||||||
'Image manager should consider two dimensions of the same picture as different')
|
'Image manager should consider two dimensions of the same picture as different'
|
||||||
|
|
||||||
# WHEN: adding the same image with first dimensions
|
# WHEN: adding the same image with first dimensions
|
||||||
self.image_manager.add_image(full_path, 'church.jpg', None, 80, 80)
|
self.image_manager.add_image(full_path, 'church.jpg', None, 80, 80)
|
||||||
|
|
||||||
# THEN: the cache should still contain only two pictures
|
# THEN: the cache should still contain only two pictures
|
||||||
self.assertEqual(len(self.image_manager._cache), 2, 'Same dimensions should not be added again')
|
assert len(self.image_manager._cache) == 2, 'Same dimensions should not be added again'
|
||||||
|
|
||||||
# WHEN: calling with correct image, but wrong dimensions
|
# WHEN: calling with correct image, but wrong dimensions
|
||||||
with self.assertRaises(KeyError) as context:
|
with self.assertRaises(KeyError) as context:
|
||||||
|
@ -291,7 +291,7 @@ class TestLib(TestCase):
|
|||||||
icon = create_thumb(image_path, thumb_path, size=thumb_size)
|
icon = create_thumb(image_path, thumb_path, size=thumb_size)
|
||||||
|
|
||||||
# THEN: Check if the thumb was created and scaled to the given size.
|
# THEN: Check if the thumb was created and scaled to the given size.
|
||||||
self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
|
assert thumb_path.exists() is True, 'Test was not ran, because the thumb already exists'
|
||||||
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
||||||
assert icon.isNull() is False, 'The icon should not be null'
|
assert icon.isNull() is False, 'The icon should not be null'
|
||||||
assert thumb_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
assert thumb_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
||||||
@ -325,7 +325,7 @@ class TestLib(TestCase):
|
|||||||
icon = create_thumb(image_path, thumb_path)
|
icon = create_thumb(image_path, thumb_path)
|
||||||
|
|
||||||
# THEN: Check if the thumb was created, retaining its aspect ratio.
|
# THEN: Check if the thumb was created, retaining its aspect ratio.
|
||||||
self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
|
assert thumb_path.exists() is True, 'Test was not ran, because the thumb already exists'
|
||||||
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
||||||
assert icon.isNull() is False, 'The icon should not be null'
|
assert icon.isNull() is False, 'The icon should not be null'
|
||||||
assert expected_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
assert expected_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
||||||
@ -430,7 +430,7 @@ class TestLib(TestCase):
|
|||||||
icon = create_thumb(image_path, thumb_path, size=thumb_size)
|
icon = create_thumb(image_path, thumb_path, size=thumb_size)
|
||||||
|
|
||||||
# THEN: Check if the thumb was created, retaining its aspect ratio.
|
# THEN: Check if the thumb was created, retaining its aspect ratio.
|
||||||
self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
|
assert thumb_path.exists() is True, 'Test was not ran, because the thumb already exists'
|
||||||
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
||||||
assert icon.isNull() is False, 'The icon should not be null'
|
assert icon.isNull() is False, 'The icon should not be null'
|
||||||
assert expected_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
assert expected_size == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
||||||
@ -468,7 +468,7 @@ class TestLib(TestCase):
|
|||||||
icon = create_thumb(image_path, thumb_path, size=None)
|
icon = create_thumb(image_path, thumb_path, size=None)
|
||||||
|
|
||||||
# THEN: Check if the thumb was created with aspect ratio of 1.
|
# THEN: Check if the thumb was created with aspect ratio of 1.
|
||||||
self.assertTrue(thumb_path.exists(), 'Test was not ran, because the thumb already exists')
|
assert thumb_path.exists() is True, 'Test was not ran, because the thumb already exists'
|
||||||
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
assert isinstance(icon, QtGui.QIcon), 'The icon should be a QIcon'
|
||||||
assert icon.isNull() is False, 'The icon should not be null'
|
assert icon.isNull() is False, 'The icon should not be null'
|
||||||
assert expected_size_1 == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
assert expected_size_1 == QtGui.QImageReader(str(thumb_path)).size(), 'The thumb should have the given size'
|
||||||
@ -789,7 +789,7 @@ class TestLib(TestCase):
|
|||||||
ret = compare_chord_lyric(chord, lyrics)
|
ret = compare_chord_lyric(chord, lyrics)
|
||||||
|
|
||||||
# THEN: The returned value should 0 because the lyric is longer than the chord
|
# THEN: The returned value should 0 because the lyric is longer than the chord
|
||||||
self.assertEquals(0, ret, 'The returned value should 0 because the lyric is longer than the chord')
|
assert 0 == ret, 'The returned value should 0 because the lyric is longer than the chord'
|
||||||
|
|
||||||
def test_compare_chord_lyric_long_chord(self):
|
def test_compare_chord_lyric_long_chord(self):
|
||||||
"""
|
"""
|
||||||
|
@ -52,7 +52,7 @@ class TestPath(TestCase):
|
|||||||
result = path_to_str(None)
|
result = path_to_str(None)
|
||||||
|
|
||||||
# THEN: `path_to_str` should return an empty string
|
# THEN: `path_to_str` should return an empty string
|
||||||
self.assertEqual(result, '')
|
assert result == ''
|
||||||
|
|
||||||
def test_path_to_str_path_object(self):
|
def test_path_to_str_path_object(self):
|
||||||
"""
|
"""
|
||||||
@ -63,7 +63,7 @@ class TestPath(TestCase):
|
|||||||
result = path_to_str(Path('test/path'))
|
result = path_to_str(Path('test/path'))
|
||||||
|
|
||||||
# THEN: `path_to_str` should return a string representation of the Path object
|
# THEN: `path_to_str` should return a string representation of the Path object
|
||||||
self.assertEqual(result, os.path.join('test', 'path'))
|
assert result == os.path.join('test', 'path')
|
||||||
|
|
||||||
def test_str_to_path_type_error(self):
|
def test_str_to_path_type_error(self):
|
||||||
"""
|
"""
|
||||||
@ -84,4 +84,4 @@ class TestPath(TestCase):
|
|||||||
result = str_to_path('')
|
result = str_to_path('')
|
||||||
|
|
||||||
# THEN: `path_to_str` should return None
|
# THEN: `path_to_str` should return None
|
||||||
self.assertEqual(result, None)
|
assert result is None
|
||||||
|
@ -159,7 +159,7 @@ class TestProjectorDB(TestCase):
|
|||||||
record = self.projector.get_projector_by_ip(TEST2_DATA['ip'])
|
record = self.projector.get_projector_by_ip(TEST2_DATA['ip'])
|
||||||
|
|
||||||
# THEN: Verify proper record returned
|
# THEN: Verify proper record returned
|
||||||
self.assertTrue(compare_data(Projector(**TEST2_DATA), record),
|
assertTrue(compare_data(Projector(**TEST2_DATA), record),
|
||||||
'Record found should have been test_2 data')
|
'Record found should have been test_2 data')
|
||||||
|
|
||||||
def test_find_record_by_name(self):
|
def test_find_record_by_name(self):
|
||||||
@ -173,7 +173,7 @@ class TestProjectorDB(TestCase):
|
|||||||
record = self.projector.get_projector_by_name(TEST2_DATA['name'])
|
record = self.projector.get_projector_by_name(TEST2_DATA['name'])
|
||||||
|
|
||||||
# THEN: Verify proper record returned
|
# THEN: Verify proper record returned
|
||||||
self.assertTrue(compare_data(Projector(**TEST2_DATA), record),
|
assertTrue(compare_data(Projector(**TEST2_DATA), record),
|
||||||
'Record found should have been test_2 data')
|
'Record found should have been test_2 data')
|
||||||
|
|
||||||
def test_record_delete(self):
|
def test_record_delete(self):
|
||||||
@ -189,7 +189,7 @@ class TestProjectorDB(TestCase):
|
|||||||
|
|
||||||
# THEN: Verify record not retrievable
|
# THEN: Verify record not retrievable
|
||||||
found = self.projector.get_projector_by_ip(TEST3_DATA['ip'])
|
found = self.projector.get_projector_by_ip(TEST3_DATA['ip'])
|
||||||
self.assertFalse(found, 'test_3 record should have been deleted')
|
assertFalse(found, 'test_3 record should have been deleted')
|
||||||
|
|
||||||
def test_record_edit(self):
|
def test_record_edit(self):
|
||||||
"""
|
"""
|
||||||
@ -214,7 +214,7 @@ class TestProjectorDB(TestCase):
|
|||||||
record.model_filter = TEST3_DATA['model_filter']
|
record.model_filter = TEST3_DATA['model_filter']
|
||||||
record.model_lamp = TEST3_DATA['model_lamp']
|
record.model_lamp = TEST3_DATA['model_lamp']
|
||||||
updated = self.projector.update_projector(record)
|
updated = self.projector.update_projector(record)
|
||||||
self.assertTrue(updated, 'Save updated record should have returned True')
|
assertTrue(updated, 'Save updated record should have returned True')
|
||||||
record = self.projector.get_projector_by_ip(TEST3_DATA['ip'])
|
record = self.projector.get_projector_by_ip(TEST3_DATA['ip'])
|
||||||
|
|
||||||
# THEN: Record ID should remain the same, but data should be changed
|
# THEN: Record ID should remain the same, but data should be changed
|
||||||
|
@ -117,8 +117,8 @@ class TestMainWindow(TestCase, TestMixin):
|
|||||||
# WHEN no changes are made to the service
|
# WHEN no changes are made to the service
|
||||||
|
|
||||||
# THEN the main window's title shoud be the same as the OpenLP string in the UiStrings class
|
# THEN the main window's title shoud be the same as the OpenLP string in the UiStrings class
|
||||||
self.assertEqual(self.main_window.windowTitle(), UiStrings().OpenLP,
|
assert self.main_window.windowTitle() == UiStrings().OpenLP, \
|
||||||
'The main window\'s title should be the same as the OpenLP string in UiStrings class')
|
'The main window\'s title should be the same as the OpenLP string in UiStrings class'
|
||||||
|
|
||||||
def test_set_service_modifed(self):
|
def test_set_service_modifed(self):
|
||||||
"""
|
"""
|
||||||
@ -204,7 +204,7 @@ class TestMainWindow(TestCase, TestMixin):
|
|||||||
self.main_window.on_search_shortcut_triggered()
|
self.main_window.on_search_shortcut_triggered()
|
||||||
|
|
||||||
# THEN: The media manager dock is made visible
|
# THEN: The media manager dock is made visible
|
||||||
self.assertEqual(0, mocked_media_manager_dock.setVisible.call_count)
|
assert 0 == mocked_media_manager_dock.setVisible.call_count
|
||||||
mocked_widget.on_focus.assert_called_with()
|
mocked_widget.on_focus.assert_called_with()
|
||||||
|
|
||||||
@patch('openlp.core.ui.mainwindow.FirstTimeForm')
|
@patch('openlp.core.ui.mainwindow.FirstTimeForm')
|
||||||
|
@ -402,7 +402,7 @@ class TestListPreviewWidget(TestCase):
|
|||||||
list_preview_widget.row_resized(0, 100, 150)
|
list_preview_widget.row_resized(0, 100, 150)
|
||||||
|
|
||||||
# THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should fail
|
# THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should fail
|
||||||
self.assertRaises(Exception)
|
assertRaises(Exception)
|
||||||
|
|
||||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.selectRow')
|
@patch(u'openlp.core.widgets.views.ListPreviewWidget.selectRow')
|
||||||
@patch(u'openlp.core.widgets.views.ListPreviewWidget.scrollToItem')
|
@patch(u'openlp.core.widgets.views.ListPreviewWidget.scrollToItem')
|
||||||
|
@ -79,5 +79,5 @@ class TestAlertManager(TestCase):
|
|||||||
alert_manager.alert_text(['This is \n a string'])
|
alert_manager.alert_text(['This is \n a string'])
|
||||||
|
|
||||||
# THEN: the display should have been triggered
|
# 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'
|
||||||
alert_manager.display_alert.assert_called_once_with('This is a string')
|
alert_manager.display_alert.assert_called_once_with('This is a string')
|
||||||
|
@ -217,7 +217,7 @@ class TestEasyWorshipSongImport(TestCase):
|
|||||||
for field_name in non_existing_fields:
|
for field_name in non_existing_fields:
|
||||||
|
|
||||||
# THEN: The importer object should not be None
|
# THEN: The importer object should not be None
|
||||||
self.assertRaises(IndexError, importer.db_find_field, field_name)
|
assertRaises(IndexError, importer.db_find_field, field_name)
|
||||||
|
|
||||||
def test_set_record_struct(self):
|
def test_set_record_struct(self):
|
||||||
"""
|
"""
|
||||||
|
@ -153,7 +153,7 @@ class TestOpenLyricsImport(TestCase, TestMixin):
|
|||||||
ol._process_formatting_tags(song_xml, False)
|
ol._process_formatting_tags(song_xml, False)
|
||||||
|
|
||||||
# THEN: New tags should have been saved
|
# THEN: New tags should have been saved
|
||||||
self.assertListEqual(json.loads(json.dumps(result_tags)),
|
assertListEqual(json.loads(json.dumps(result_tags)),
|
||||||
json.loads(str(Settings().value('formattingTags/html_tags'))),
|
json.loads(str(Settings().value('formattingTags/html_tags'))),
|
||||||
'The formatting tags should contain both the old and the new')
|
'The formatting tags should contain both the old and the new')
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ class TestSongUsage(TestCase):
|
|||||||
# THEN: about() should return a string object
|
# THEN: about() should return a string object
|
||||||
assert isinstance(SongUsagePlugin.about(), str)
|
assert isinstance(SongUsagePlugin.about(), str)
|
||||||
# THEN: about() should return a non-empty string
|
# THEN: about() should return a non-empty string
|
||||||
self.assertNotEquals(len(SongUsagePlugin.about()), 0)
|
assertNotEquals(len(SongUsagePlugin.about()), 0)
|
||||||
self.assertNotEquals(len(SongUsagePlugin.about()), 0)
|
assertNotEquals(len(SongUsagePlugin.about()), 0)
|
||||||
|
|
||||||
@patch('openlp.plugins.songusage.songusageplugin.Manager')
|
@patch('openlp.plugins.songusage.songusageplugin.Manager')
|
||||||
def test_song_usage_init(self, MockedManager):
|
def test_song_usage_init(self, MockedManager):
|
||||||
|
@ -108,7 +108,7 @@ class SongImportTestHelper(TestCase):
|
|||||||
verse_order_list = self._get_data(result_data, 'verse_order_list')
|
verse_order_list = self._get_data(result_data, 'verse_order_list')
|
||||||
|
|
||||||
# THEN: do_import should return none, the song data should be as expected, and finish should have been called.
|
# THEN: do_import should return none, the song data should be as expected, and finish should have been called.
|
||||||
self.assertIsNone(importer.do_import(), 'do_import should return None when it has completed')
|
assert importer.do_import() is None, 'do_import should return None when it has completed'
|
||||||
|
|
||||||
# Debug information - will be displayed when the test fails
|
# Debug information - will be displayed when the test fails
|
||||||
log.debug("Title imported: %s" % importer.title)
|
log.debug("Title imported: %s" % importer.title)
|
||||||
@ -122,7 +122,7 @@ class SongImportTestHelper(TestCase):
|
|||||||
log.debug("Song copyright imported: %s" % importer.song_number)
|
log.debug("Song copyright imported: %s" % importer.song_number)
|
||||||
log.debug("Topics imported: %s" % importer.topics)
|
log.debug("Topics imported: %s" % importer.topics)
|
||||||
|
|
||||||
self.assertEqual(importer.title, title, 'title for %s should be "%s"' % (source_file_name, title))
|
assert importer.title == title, 'title for %s should be "%s"' % (source_file_name, title)
|
||||||
for author in author_calls:
|
for author in author_calls:
|
||||||
if isinstance(author, str):
|
if isinstance(author, str):
|
||||||
self.mocked_add_author.assert_any_call(author)
|
self.mocked_add_author.assert_any_call(author)
|
||||||
@ -131,27 +131,27 @@ class SongImportTestHelper(TestCase):
|
|||||||
if song_copyright:
|
if song_copyright:
|
||||||
self.mocked_add_copyright.assert_called_with(song_copyright)
|
self.mocked_add_copyright.assert_called_with(song_copyright)
|
||||||
if ccli_number:
|
if ccli_number:
|
||||||
self.assertEqual(importer.ccli_number, ccli_number,
|
assert importer.ccli_number == ccli_number, \
|
||||||
'ccli_number for %s should be %s' % (source_file_name, ccli_number))
|
'ccli_number for %s should be %s' % (source_file_name, ccli_number)
|
||||||
expected_calls = []
|
expected_calls = []
|
||||||
for verse_text, verse_tag in add_verse_calls:
|
for verse_text, verse_tag in add_verse_calls:
|
||||||
self.mocked_add_verse.assert_any_call(verse_text, verse_tag)
|
self.mocked_add_verse.assert_any_call(verse_text, verse_tag)
|
||||||
expected_calls.append(call(verse_text, verse_tag))
|
expected_calls.append(call(verse_text, verse_tag))
|
||||||
self.mocked_add_verse.assert_has_calls(expected_calls, any_order=False)
|
self.mocked_add_verse.assert_has_calls(expected_calls, any_order=False)
|
||||||
if topics:
|
if topics:
|
||||||
self.assertEqual(importer.topics, topics, 'topics for %s should be %s' % (source_file_name, topics))
|
assert importer.topics == topics, 'topics for %s should be %s' % (source_file_name, topics)
|
||||||
if comments:
|
if comments:
|
||||||
self.assertEqual(importer.comments, comments,
|
assert importer.comments == comments, \
|
||||||
'comments for %s should be "%s"' % (source_file_name, comments))
|
'comments for %s should be "%s"' % (source_file_name, comments)
|
||||||
if song_book_name:
|
if song_book_name:
|
||||||
self.assertEqual(importer.song_book_name, song_book_name,
|
assert importer.song_book_name == song_book_name, \
|
||||||
'song_book_name for %s should be "%s"' % (source_file_name, song_book_name))
|
'song_book_name for %s should be "%s"' % (source_file_name, song_book_name)
|
||||||
if song_number:
|
if song_number:
|
||||||
self.assertEqual(importer.song_number, song_number,
|
assert importer.song_number == song_number, \
|
||||||
'song_number for %s should be %s' % (source_file_name, song_number))
|
'song_number for %s should be %s' % (source_file_name, song_number)
|
||||||
if verse_order_list:
|
if verse_order_list:
|
||||||
self.assertEqual(importer.verse_order_list, verse_order_list,
|
assert importer.verse_order_list == verse_order_list, \
|
||||||
'verse_order_list for %s should be %s' % (source_file_name, verse_order_list))
|
'verse_order_list for %s should be %s' % (source_file_name, verse_order_list)
|
||||||
self.mocked_finish.assert_called_with()
|
self.mocked_finish.assert_called_with()
|
||||||
|
|
||||||
def _get_data(self, data, key):
|
def _get_data(self, data, key):
|
||||||
|
@ -86,11 +86,11 @@ class TestPluginManager(TestCase, TestMixin):
|
|||||||
|
|
||||||
# THEN: We should find the "Songs", "Bibles", etc in the plugins list
|
# THEN: We should find the "Songs", "Bibles", etc in the plugins list
|
||||||
plugin_names = [plugin.name for plugin in plugin_manager.plugins]
|
plugin_names = [plugin.name for plugin in plugin_manager.plugins]
|
||||||
self.assertIn('songs', plugin_names, 'There should be a "songs" plugin')
|
assertIn('songs', plugin_names, 'There should be a "songs" plugin')
|
||||||
self.assertIn('bibles', plugin_names, 'There should be a "bibles" plugin')
|
assertIn('bibles', plugin_names, 'There should be a "bibles" plugin')
|
||||||
self.assertIn('presentations', plugin_names, 'There should be a "presentations" plugin')
|
assertIn('presentations', plugin_names, 'There should be a "presentations" plugin')
|
||||||
self.assertIn('images', plugin_names, 'There should be a "images" plugin')
|
assertIn('images', plugin_names, 'There should be a "images" plugin')
|
||||||
self.assertIn('media', plugin_names, 'There should be a "media" plugin')
|
assertIn('media', plugin_names, 'There should be a "media" plugin')
|
||||||
self.assertIn('custom', plugin_names, 'There should be a "custom" plugin')
|
assertIn('custom', plugin_names, 'There should be a "custom" plugin')
|
||||||
self.assertIn('songusage', plugin_names, 'There should be a "songusage" plugin')
|
assertIn('songusage', plugin_names, 'There should be a "songusage" plugin')
|
||||||
self.assertIn('alerts', plugin_names, 'There should be a "alerts" plugin')
|
assertIn('alerts', plugin_names, 'There should be a "alerts" plugin')
|
||||||
|
@ -46,5 +46,4 @@ class TestMediainfoWrapper(TestCase):
|
|||||||
results = MediaInfoWrapper.parse(full_path)
|
results = MediaInfoWrapper.parse(full_path)
|
||||||
|
|
||||||
# THEN you can determine the run time
|
# THEN you can determine the run time
|
||||||
self.assertEqual(results.tracks[0].duration, test_data[1], 'The correct duration is returned for ' +
|
assert results.tracks[0].duration == test_data[1], 'The correct duration is returned for ' + test_data[0]
|
||||||
test_data[0])
|
|
||||||
|
@ -63,19 +63,19 @@ class TestStartFileRenameForm(TestCase, TestMixin):
|
|||||||
self.form.exec()
|
self.form.exec()
|
||||||
|
|
||||||
# THEN: the window title is set correctly
|
# THEN: the window title is set correctly
|
||||||
self.assertEqual(self.form.windowTitle(), 'File Rename', 'The window title should be "File Rename"')
|
assert self.form.windowTitle() == 'File Rename', 'The window title should be "File Rename"'
|
||||||
|
|
||||||
# WHEN: The form is executed with False arg
|
# WHEN: The form is executed with False arg
|
||||||
self.form.exec(False)
|
self.form.exec(False)
|
||||||
|
|
||||||
# THEN: the window title is set correctly
|
# THEN: the window title is set correctly
|
||||||
self.assertEqual(self.form.windowTitle(), 'File Rename', 'The window title should be "File Rename"')
|
assert self.form.windowTitle() == 'File Rename', 'The window title should be "File Rename"'
|
||||||
|
|
||||||
# WHEN: The form is executed with True arg
|
# WHEN: The form is executed with True arg
|
||||||
self.form.exec(True)
|
self.form.exec(True)
|
||||||
|
|
||||||
# THEN: the window title is set correctly
|
# THEN: the window title is set correctly
|
||||||
self.assertEqual(self.form.windowTitle(), 'File Copy', 'The window title should be "File Copy"')
|
assert self.form.windowTitle() == 'File Copy', 'The window title should be "File Copy"'
|
||||||
|
|
||||||
def test_line_edit_focus(self):
|
def test_line_edit_focus(self):
|
||||||
"""
|
"""
|
||||||
@ -104,4 +104,4 @@ class TestStartFileRenameForm(TestCase, TestMixin):
|
|||||||
|
|
||||||
# THEN: The text in the QLineEdit should be the same as the input string with the invalid characters filtered
|
# THEN: The text in the QLineEdit should be the same as the input string with the invalid characters filtered
|
||||||
# out.
|
# out.
|
||||||
self.assertEqual(self.form.file_name_edit.text(), 'Invalid File Name')
|
assert self.form.file_name_edit.text() == 'Invalid File Name'
|
||||||
|
@ -70,8 +70,8 @@ class TestProjectorManager(TestCase, TestMixin):
|
|||||||
# WHEN: we call bootstrap_initialise
|
# WHEN: we call bootstrap_initialise
|
||||||
self.projector_manager.bootstrap_initialise()
|
self.projector_manager.bootstrap_initialise()
|
||||||
# THEN: ProjectorDB is setup
|
# THEN: ProjectorDB is setup
|
||||||
self.assertEqual(type(self.projector_manager.projectordb), ProjectorDB,
|
assert type(self.projector_manager.projectordb) == ProjectorDB, \
|
||||||
'Initialization should have created a ProjectorDB() instance')
|
'Initialization should have created a ProjectorDB() instance'
|
||||||
|
|
||||||
def test_bootstrap_post_set_up(self):
|
def test_bootstrap_post_set_up(self):
|
||||||
"""
|
"""
|
||||||
@ -85,10 +85,9 @@ class TestProjectorManager(TestCase, TestMixin):
|
|||||||
self.projector_manager.bootstrap_post_set_up()
|
self.projector_manager.bootstrap_post_set_up()
|
||||||
|
|
||||||
# THEN: verify calls to retrieve saved projectors and edit page initialized
|
# THEN: verify calls to retrieve saved projectors and edit page initialized
|
||||||
self.assertEqual(1, self.projector_manager._load_projectors.call_count,
|
assert 1 == self.projector_manager._load_projectors.call_count, \
|
||||||
'Initialization should have called load_projectors()')
|
'Initialization should have called load_projectors()'
|
||||||
self.assertEqual(type(self.projector_manager.projector_form), ProjectorEditForm,
|
assert type(self.projector_manager.projector_form) == ProjectorEditForm, \
|
||||||
'Initialization should have created a Projector Edit Form')
|
'Initialization should have created a Projector Edit Form'
|
||||||
self.assertIs(self.projector_manager.projectordb,
|
assert self.projector_manager.projectordb is self.projector_manager.projector_form.projectordb, \
|
||||||
self.projector_manager.projector_form.projectordb,
|
'ProjectorEditForm should be using same ProjectorDB() instance as ProjectorManager'
|
||||||
'ProjectorEditForm should be using same ProjectorDB() instance as ProjectorManager')
|
|
||||||
|
@ -111,8 +111,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
|
|||||||
check = source_group(codes, PJLINK_DEFAULT_CODES)
|
check = source_group(codes, PJLINK_DEFAULT_CODES)
|
||||||
|
|
||||||
# THEN: return dictionary should match test dictionary
|
# THEN: return dictionary should match test dictionary
|
||||||
self.assertEquals(check, build_source_dict(),
|
assert check == build_source_dict(), "Source group dictionary should match test dictionary"
|
||||||
"Source group dictionary should match test dictionary")
|
|
||||||
|
|
||||||
@patch.object(QDialog, 'exec')
|
@patch.object(QDialog, 'exec')
|
||||||
def test_source_select_edit_button(self, mocked_qdialog):
|
def test_source_select_edit_button(self, mocked_qdialog):
|
||||||
@ -130,9 +129,8 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
|
|||||||
projector = select_form.projector
|
projector = select_form.projector
|
||||||
|
|
||||||
# THEN: Verify all 4 buttons are available
|
# THEN: Verify all 4 buttons are available
|
||||||
self.assertEquals(len(select_form.button_box.buttons()), 4,
|
assert len(select_form.button_box.buttons()) == 4, \
|
||||||
'SourceSelect dialog box should have "OK", "Cancel" '
|
'SourceSelect dialog box should have "OK", "Cancel", "Rest", and "Revert" buttons available'
|
||||||
'"Rest", and "Revert" buttons available')
|
|
||||||
|
|
||||||
@patch.object(QDialog, 'exec')
|
@patch.object(QDialog, 'exec')
|
||||||
def test_source_select_noedit_button(self, mocked_qdialog):
|
def test_source_select_noedit_button(self, mocked_qdialog):
|
||||||
@ -150,6 +148,5 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
|
|||||||
projector = select_form.projector
|
projector = select_form.projector
|
||||||
|
|
||||||
# THEN: Verify only 2 buttons are available
|
# THEN: Verify only 2 buttons are available
|
||||||
self.assertEquals(len(select_form.button_box.buttons()), 2,
|
assert len(select_form.button_box.buttons()) == 2, \
|
||||||
'SourceSelect dialog box should only have "OK" '
|
'SourceSelect dialog box should only have "OK" and "Cancel" buttons available'
|
||||||
'and "Cancel" buttons available')
|
|
||||||
|
@ -79,8 +79,8 @@ class TestServiceManager(TestCase, TestMixin):
|
|||||||
self.service_manager.setup_ui(self.service_manager)
|
self.service_manager.setup_ui(self.service_manager)
|
||||||
|
|
||||||
# THEN the count of items should be zero
|
# THEN the count of items should be zero
|
||||||
self.assertEqual(self.service_manager.service_manager_list.topLevelItemCount(), 0,
|
assert self.service_manager.service_manager_list.topLevelItemCount() == 0, \
|
||||||
'The service manager list should be empty ')
|
'The service manager list should be empty '
|
||||||
|
|
||||||
@patch('openlp.core.ui.servicemanager.QtWidgets.QTreeWidget.itemAt')
|
@patch('openlp.core.ui.servicemanager.QtWidgets.QTreeWidget.itemAt')
|
||||||
@patch('openlp.core.ui.servicemanager.QtWidgets.QWidget.mapToGlobal')
|
@patch('openlp.core.ui.servicemanager.QtWidgets.QWidget.mapToGlobal')
|
||||||
@ -447,8 +447,8 @@ class TestServiceManager(TestCase, TestMixin):
|
|||||||
# THEN selection should be expanded
|
# THEN selection should be expanded
|
||||||
selected_index = self.service_manager.service_manager_list.currentIndex()
|
selected_index = self.service_manager.service_manager_list.currentIndex()
|
||||||
above_selected_index = self.service_manager.service_manager_list.indexAbove(selected_index)
|
above_selected_index = self.service_manager.service_manager_list.indexAbove(selected_index)
|
||||||
self.assertTrue(self.service_manager.service_manager_list.isExpanded(above_selected_index),
|
assert self.service_manager.service_manager_list.isExpanded(above_selected_index is True, \
|
||||||
'Item should have been expanded')
|
'Item should have been expanded'
|
||||||
self.service_manager.expanded.assert_called_once_with(song_item)
|
self.service_manager.expanded.assert_called_once_with(song_item)
|
||||||
|
|
||||||
def test_on_collapse_selection_with_parent_selected(self):
|
def test_on_collapse_selection_with_parent_selected(self):
|
||||||
@ -468,10 +468,10 @@ class TestServiceManager(TestCase, TestMixin):
|
|||||||
|
|
||||||
# THEN selection should be expanded
|
# THEN selection should be expanded
|
||||||
selected_index = self.service_manager.service_manager_list.currentIndex()
|
selected_index = self.service_manager.service_manager_list.currentIndex()
|
||||||
self.assertFalse(self.service_manager.service_manager_list.isExpanded(selected_index),
|
assert self.service_manager.service_manager_list.isExpanded(selected_index) is False, \
|
||||||
'Item should have been collapsed')
|
'Item should have been collapsed'
|
||||||
self.assertTrue(self.service_manager.service_manager_list.currentItem() == song_item,
|
assert self.service_manager.service_manager_list.currentItem() == song_item is True, \
|
||||||
'Top item should have been selected')
|
'Top item should have been selected'
|
||||||
self.service_manager.collapsed.assert_called_once_with(song_item)
|
self.service_manager.collapsed.assert_called_once_with(song_item)
|
||||||
|
|
||||||
def test_on_collapse_selection_with_child_selected(self):
|
def test_on_collapse_selection_with_child_selected(self):
|
||||||
@ -491,8 +491,8 @@ class TestServiceManager(TestCase, TestMixin):
|
|||||||
|
|
||||||
# THEN selection should be expanded
|
# THEN selection should be expanded
|
||||||
selected_index = self.service_manager.service_manager_list.currentIndex()
|
selected_index = self.service_manager.service_manager_list.currentIndex()
|
||||||
self.assertFalse(self.service_manager.service_manager_list.isExpanded(selected_index),
|
assert self.service_manager.service_manager_list.isExpanded(selected_index) is False, \
|
||||||
'Item should have been collapsed')
|
'Item should have been collapsed'
|
||||||
self.assertTrue(self.service_manager.service_manager_list.currentItem() == song_item,
|
assert self.service_manager.service_manager_list.currentItem() == song_item is True, \
|
||||||
'Top item should have been selected')
|
'Top item should have been selected'
|
||||||
self.service_manager.collapsed.assert_called_once_with(song_item)
|
self.service_manager.collapsed.assert_called_once_with(song_item)
|
||||||
|
@ -66,7 +66,7 @@ class TestStartNoteDialog(TestCase, TestMixin):
|
|||||||
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
|
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
|
||||||
|
|
||||||
# THEN the following input text is returned
|
# THEN the following input text is returned
|
||||||
self.assertEqual(self.form.text_edit.toPlainText(), '', 'The returned text should be empty')
|
assert self.form.text_edit.toPlainText() == '', 'The returned text should be empty'
|
||||||
|
|
||||||
# WHEN displaying the UI, having set the text and pressing enter
|
# WHEN displaying the UI, having set the text and pressing enter
|
||||||
text = 'OpenLP is the best worship software'
|
text = 'OpenLP is the best worship software'
|
||||||
@ -77,7 +77,7 @@ class TestStartNoteDialog(TestCase, TestMixin):
|
|||||||
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
|
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
|
||||||
|
|
||||||
# THEN the following text is returned
|
# THEN the following text is returned
|
||||||
self.assertEqual(self.form.text_edit.toPlainText(), text, 'The text originally entered should still be there')
|
assert self.form.text_edit.toPlainText() == text, 'The text originally entered should still be there'
|
||||||
|
|
||||||
# WHEN displaying the UI, having set the text and pressing enter
|
# WHEN displaying the UI, having set the text and pressing enter
|
||||||
self.form.text_edit.setPlainText('')
|
self.form.text_edit.setPlainText('')
|
||||||
@ -88,4 +88,4 @@ class TestStartNoteDialog(TestCase, TestMixin):
|
|||||||
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
|
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
|
||||||
|
|
||||||
# THEN the following text is returned
|
# THEN the following text is returned
|
||||||
self.assertEqual(self.form.text_edit.toPlainText(), text, 'The new text should be returned')
|
assert self.form.text_edit.toPlainText() == text, 'The new text should be returned'
|
||||||
|
@ -67,9 +67,9 @@ class TestShortcutform(TestCase, TestMixin):
|
|||||||
self.form._adjust_button(button, checked, enabled, text)
|
self.form._adjust_button(button, checked, enabled, text)
|
||||||
|
|
||||||
# THEN: The button should be changed.
|
# THEN: The button should be changed.
|
||||||
self.assertEqual(button.text(), text, 'The text should match.')
|
assert button.text() == text, 'The text should match.'
|
||||||
mocked_check_method.assert_called_once_with(True)
|
mocked_check_method.assert_called_once_with(True)
|
||||||
self.assertEqual(button.isEnabled(), enabled, 'The button should be disabled.')
|
assert button.isEnabled() == enabled, 'The button should be disabled.'
|
||||||
|
|
||||||
def test_space_key_press_event(self):
|
def test_space_key_press_event(self):
|
||||||
"""
|
"""
|
||||||
@ -85,7 +85,7 @@ class TestShortcutform(TestCase, TestMixin):
|
|||||||
|
|
||||||
# THEN: The key should be released
|
# THEN: The key should be released
|
||||||
mocked_key_release_event.assert_called_with(mocked_event)
|
mocked_key_release_event.assert_called_with(mocked_event)
|
||||||
self.assertEqual(0, mocked_event.accept.call_count)
|
assert 0 == mocked_event.accept.call_count
|
||||||
|
|
||||||
def test_primary_push_button_checked_key_press_event(self):
|
def test_primary_push_button_checked_key_press_event(self):
|
||||||
"""
|
"""
|
||||||
@ -102,7 +102,7 @@ class TestShortcutform(TestCase, TestMixin):
|
|||||||
|
|
||||||
# THEN: The key should be released
|
# THEN: The key should be released
|
||||||
mocked_key_release_event.assert_called_with(mocked_event)
|
mocked_key_release_event.assert_called_with(mocked_event)
|
||||||
self.assertEqual(0, mocked_event.accept.call_count)
|
assert 0 == mocked_event.accept.call_count
|
||||||
|
|
||||||
def test_alternate_push_button_checked_key_press_event(self):
|
def test_alternate_push_button_checked_key_press_event(self):
|
||||||
"""
|
"""
|
||||||
@ -119,7 +119,7 @@ class TestShortcutform(TestCase, TestMixin):
|
|||||||
|
|
||||||
# THEN: The key should be released
|
# THEN: The key should be released
|
||||||
mocked_key_release_event.assert_called_with(mocked_event)
|
mocked_key_release_event.assert_called_with(mocked_event)
|
||||||
self.assertEqual(0, mocked_event.accept.call_count)
|
assert 0 == mocked_event.accept.call_count
|
||||||
|
|
||||||
def test_escape_key_press_event(self):
|
def test_escape_key_press_event(self):
|
||||||
"""
|
"""
|
||||||
@ -148,7 +148,7 @@ class TestShortcutform(TestCase, TestMixin):
|
|||||||
self.form.on_default_radio_button_clicked(False)
|
self.form.on_default_radio_button_clicked(False)
|
||||||
|
|
||||||
# THEN: The method should exit early (i.e. the rest of the methods are not called)
|
# THEN: The method should exit early (i.e. the rest of the methods are not called)
|
||||||
self.assertEqual(0, mocked_current_item_action.call_count)
|
assert 0 == mocked_current_item_action.call_count
|
||||||
|
|
||||||
def test_on_default_radio_button_clicked_no_action(self):
|
def test_on_default_radio_button_clicked_no_action(self):
|
||||||
"""
|
"""
|
||||||
@ -164,7 +164,7 @@ class TestShortcutform(TestCase, TestMixin):
|
|||||||
|
|
||||||
# THEN: The method should exit early (i.e. the rest of the methods are not called)
|
# THEN: The method should exit early (i.e. the rest of the methods are not called)
|
||||||
mocked_current_item_action.assert_called_with()
|
mocked_current_item_action.assert_called_with()
|
||||||
self.assertEqual(0, mocked_action_shortcuts.call_count)
|
assert 0 == mocked_action_shortcuts.call_count
|
||||||
|
|
||||||
def test_on_default_radio_button_clicked(self):
|
def test_on_default_radio_button_clicked(self):
|
||||||
"""
|
"""
|
||||||
@ -202,7 +202,7 @@ class TestShortcutform(TestCase, TestMixin):
|
|||||||
self.form.on_custom_radio_button_clicked(False)
|
self.form.on_custom_radio_button_clicked(False)
|
||||||
|
|
||||||
# THEN: The method should exit early (i.e. the rest of the methods are not called)
|
# THEN: The method should exit early (i.e. the rest of the methods are not called)
|
||||||
self.assertEqual(0, mocked_current_item_action.call_count)
|
assert 0 == mocked_current_item_action.call_count
|
||||||
|
|
||||||
def test_on_custom_radio_button_clicked(self):
|
def test_on_custom_radio_button_clicked(self):
|
||||||
"""
|
"""
|
||||||
|
@ -56,28 +56,24 @@ class TestStartTimeDialog(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
Test StartTimeDialog are defaults correct
|
Test StartTimeDialog are defaults correct
|
||||||
"""
|
"""
|
||||||
self.assertEqual(self.form.hour_spin_box.minimum(), 0, 'The minimum hour should stay the same as the dialog')
|
assert self.form.hour_spin_box.minimum() == 0, 'The minimum hour should stay the same as the dialog'
|
||||||
self.assertEqual(self.form.hour_spin_box.maximum(), 4, 'The maximum hour should stay the same as the dialog')
|
assert self.form.hour_spin_box.maximum() == 4, 'The maximum hour should stay the same as the dialog'
|
||||||
self.assertEqual(self.form.minute_spin_box.minimum(), 0,
|
assert self.form.minute_spin_box.minimum() == 0, 'The minimum minute should stay the same as the dialog'
|
||||||
'The minimum minute should stay the same as the dialog')
|
assert self.form.minute_spin_box.maximum() == 59, 'The maximum minute should stay the same as the dialog'
|
||||||
self.assertEqual(self.form.minute_spin_box.maximum(), 59,
|
assert self.form.second_spin_box.minimum() == 0, 'The minimum second should stay the same as the dialog'
|
||||||
'The maximum minute should stay the same as the dialog')
|
assert self.form.second_spin_box.maximum() == 59, 'The maximum second should stay the same as the dialog'
|
||||||
self.assertEqual(self.form.second_spin_box.minimum(), 0,
|
assert self.form.hour_finish_spin_box.minimum() == 0, \
|
||||||
'The minimum second should stay the same as the dialog')
|
'The minimum finish hour should stay the same as the dialog'
|
||||||
self.assertEqual(self.form.second_spin_box.maximum(), 59,
|
assert self.form.hour_finish_spin_box.maximum() == 4, \
|
||||||
'The maximum second should stay the same as the dialog')
|
'The maximum finish hour should stay the same as the dialog'
|
||||||
self.assertEqual(self.form.hour_finish_spin_box.minimum(), 0,
|
assert self.form.minute_finish_spin_box.minimum() == 0, \
|
||||||
'The minimum finish hour should stay the same as the dialog')
|
'The minimum finish minute should stay the same as the dialog'
|
||||||
self.assertEqual(self.form.hour_finish_spin_box.maximum(), 4,
|
assert self.form.minute_finish_spin_box.maximum() == 59, \
|
||||||
'The maximum finish hour should stay the same as the dialog')
|
'The maximum finish minute should stay the same as the dialog'
|
||||||
self.assertEqual(self.form.minute_finish_spin_box.minimum(), 0,
|
assert self.form.second_finish_spin_box.minimum() == 0, \
|
||||||
'The minimum finish minute should stay the same as the dialog')
|
'The minimum finish second should stay the same as the dialog'
|
||||||
self.assertEqual(self.form.minute_finish_spin_box.maximum(), 59,
|
assert self.form.second_finish_spin_box.maximum() == 59, \
|
||||||
'The maximum finish minute should stay the same as the dialog')
|
'The maximum finish second should stay the same as the dialog'
|
||||||
self.assertEqual(self.form.second_finish_spin_box.minimum(), 0,
|
|
||||||
'The minimum finish second should stay the same as the dialog')
|
|
||||||
self.assertEqual(self.form.second_finish_spin_box.maximum(), 59,
|
|
||||||
'The maximum finish second should stay the same as the dialog')
|
|
||||||
|
|
||||||
def test_time_display(self):
|
def test_time_display(self):
|
||||||
"""
|
"""
|
||||||
@ -97,10 +93,10 @@ class TestStartTimeDialog(TestCase, TestMixin):
|
|||||||
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
|
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
|
||||||
|
|
||||||
# THEN the following input values are returned
|
# THEN the following input values are returned
|
||||||
self.assertEqual(self.form.hour_spin_box.value(), 0)
|
assert self.form.hour_spin_box.value() == 0
|
||||||
self.assertEqual(self.form.minute_spin_box.value(), 1)
|
assert self.form.minute_spin_box.value() == 1
|
||||||
self.assertEqual(self.form.second_spin_box.value(), 1)
|
assert self.form.second_spin_box.value() == 1
|
||||||
self.assertEqual(self.form.item['service_item'].start_time, 61, 'The start time should stay the same')
|
assert self.form.item['service_item'].start_time == 61, 'The start time should stay the same'
|
||||||
|
|
||||||
# WHEN displaying the UI, changing the time to 2min 3secs and pressing enter
|
# WHEN displaying the UI, changing the time to 2min 3secs and pressing enter
|
||||||
self.form.item = {'service_item': mocked_serviceitem}
|
self.form.item = {'service_item': mocked_serviceitem}
|
||||||
@ -112,7 +108,7 @@ class TestStartTimeDialog(TestCase, TestMixin):
|
|||||||
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
|
QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton)
|
||||||
|
|
||||||
# THEN the following values are returned
|
# THEN the following values are returned
|
||||||
self.assertEqual(self.form.hour_spin_box.value(), 0)
|
assert self.form.hour_spin_box.value() == 0
|
||||||
self.assertEqual(self.form.minute_spin_box.value(), 2)
|
assert self.form.minute_spin_box.value() == 2
|
||||||
self.assertEqual(self.form.second_spin_box.value(), 3)
|
assert self.form.second_spin_box.value() == 3
|
||||||
self.assertEqual(self.form.item['service_item'].start_time, 123, 'The start time should have changed')
|
assert self.form.item['service_item'].start_time == 123, 'The start time should have changed'
|
||||||
|
@ -121,4 +121,4 @@ class TestThemeManager(TestCase, TestMixin):
|
|||||||
self.theme_manager.bootstrap_post_set_up()
|
self.theme_manager.bootstrap_post_set_up()
|
||||||
|
|
||||||
# THEN:
|
# THEN:
|
||||||
self.assertEqual(1, self.theme_manager.load_themes.call_count, "load_themes should have been called once")
|
assert 1 == self.theme_manager.load_themes.call_count, "load_themes should have been called once"
|
||||||
|
@ -86,8 +86,8 @@ class TestSearchEdit(TestCase, TestMixin):
|
|||||||
|
|
||||||
# THEN: The first search type should be the first one in the list. The selected type should be saved in the
|
# THEN: The first search type should be the first one in the list. The selected type should be saved in the
|
||||||
# settings
|
# settings
|
||||||
self.assertEqual(self.search_edit.current_search_type(), SearchTypes.First,
|
assert self.search_edit.current_search_type() == SearchTypes.First, \
|
||||||
"The first search type should be selected.")
|
"The first search type should be selected."
|
||||||
self.mocked_settings().setValue.assert_called_once_with('settings_section/last used search type', 0)
|
self.mocked_settings().setValue.assert_called_once_with('settings_section/last used search type', 0)
|
||||||
|
|
||||||
def test_set_current_search_type(self):
|
def test_set_current_search_type(self):
|
||||||
@ -99,11 +99,11 @@ class TestSearchEdit(TestCase, TestMixin):
|
|||||||
result = self.search_edit.set_current_search_type(SearchTypes.Second)
|
result = self.search_edit.set_current_search_type(SearchTypes.Second)
|
||||||
|
|
||||||
# THEN:
|
# THEN:
|
||||||
self.assertTrue(result, "The call should return success (True).")
|
assert result is True, "The call should return success (True)."
|
||||||
self.assertEqual(self.search_edit.current_search_type(), SearchTypes.Second,
|
assert self.search_edit.current_search_type() == SearchTypes.Second, \
|
||||||
"The search type should be SearchTypes.Second")
|
"The search type should be SearchTypes.Second"
|
||||||
self.assertEqual(self.search_edit.placeholderText(), SECOND_PLACEHOLDER_TEXT,
|
assert self.search_edit.placeholderText() == SECOND_PLACEHOLDER_TEXT, \
|
||||||
"The correct placeholder text should be 'Second Placeholder Text'.")
|
"The correct placeholder text should be 'Second Placeholder Text'."
|
||||||
self.mocked_settings().setValue.assert_has_calls(
|
self.mocked_settings().setValue.assert_has_calls(
|
||||||
[call('settings_section/last used search type', 0), call('settings_section/last used search type', 1)])
|
[call('settings_section/last used search type', 0), call('settings_section/last used search type', 1)])
|
||||||
|
|
||||||
@ -166,4 +166,4 @@ class TestHistoryComboBox(TestCase, TestMixin):
|
|||||||
self.combo.addItem('test2')
|
self.combo.addItem('test2')
|
||||||
|
|
||||||
# THEN: The list of items should contain both strings.
|
# THEN: The list of items should contain both strings.
|
||||||
self.assertEqual(self.combo.getItems(), ['test1', 'test2'])
|
assert self.combo.getItems() == ['test1', 'test2']
|
||||||
|
@ -64,7 +64,7 @@ class TestListPreviewWidget(TestCase, TestMixin):
|
|||||||
# GIVEN: A new ListPreviewWidget instance.
|
# GIVEN: A new ListPreviewWidget instance.
|
||||||
# WHEN: No SlideItem has been added yet.
|
# WHEN: No SlideItem has been added yet.
|
||||||
# THEN: The count of items should be zero.
|
# THEN: The count of items should be zero.
|
||||||
self.assertEqual(self.preview_widget.slide_count(), 0, 'The slide list should be empty.')
|
assert self.preview_widget.slide_count() == 0, 'The slide list should be empty.'
|
||||||
|
|
||||||
def test_initial_slide_number(self):
|
def test_initial_slide_number(self):
|
||||||
"""
|
"""
|
||||||
@ -73,7 +73,7 @@ class TestListPreviewWidget(TestCase, TestMixin):
|
|||||||
# GIVEN: A new ListPreviewWidget instance.
|
# GIVEN: A new ListPreviewWidget instance.
|
||||||
# WHEN: No SlideItem has been added yet.
|
# WHEN: No SlideItem has been added yet.
|
||||||
# THEN: The number of the current item should be -1.
|
# THEN: The number of the current item should be -1.
|
||||||
self.assertEqual(self.preview_widget.current_slide_number(), -1, 'The slide number should be -1.')
|
assert self.preview_widget.current_slide_number() == -1, 'The slide number should be -1.'
|
||||||
|
|
||||||
def test_replace_service_item(self):
|
def test_replace_service_item(self):
|
||||||
"""
|
"""
|
||||||
@ -87,8 +87,8 @@ class TestListPreviewWidget(TestCase, TestMixin):
|
|||||||
# WHEN: Added to the preview widget.
|
# WHEN: Added to the preview widget.
|
||||||
self.preview_widget.replace_service_item(service_item, 1, 1)
|
self.preview_widget.replace_service_item(service_item, 1, 1)
|
||||||
# THEN: The slide count and number should fit.
|
# THEN: The slide count and number should fit.
|
||||||
self.assertEqual(self.preview_widget.slide_count(), 2, 'The slide count should be 2.')
|
assert self.preview_widget.slide_count() == 2, 'The slide count should be 2.'
|
||||||
self.assertEqual(self.preview_widget.current_slide_number(), 1, 'The current slide number should be 1.')
|
assert self.preview_widget.current_slide_number() == 1, 'The current slide number should be 1.'
|
||||||
|
|
||||||
def test_change_slide(self):
|
def test_change_slide(self):
|
||||||
"""
|
"""
|
||||||
@ -103,4 +103,4 @@ class TestListPreviewWidget(TestCase, TestMixin):
|
|||||||
self.preview_widget.replace_service_item(service_item, 1, 0)
|
self.preview_widget.replace_service_item(service_item, 1, 0)
|
||||||
self.preview_widget.change_slide(1)
|
self.preview_widget.change_slide(1)
|
||||||
# THEN: The current_slide_number should reflect the change.
|
# THEN: The current_slide_number should reflect the change.
|
||||||
self.assertEqual(self.preview_widget.current_slide_number(), 1, 'The current slide number should be 1.')
|
assert self.preview_widget.current_slide_number() == 1, 'The current slide number should be 1.'
|
||||||
|
@ -78,7 +78,7 @@ class TestBibleImportForm(TestCase, TestMixin):
|
|||||||
self.form.on_web_update_button_clicked()
|
self.form.on_web_update_button_clicked()
|
||||||
|
|
||||||
# THEN: The webbible list should still be empty
|
# THEN: The webbible list should still be empty
|
||||||
self.assertEqual(self.form.web_bible_list, {}, 'The webbible list should be empty')
|
assert self.form.web_bible_list == {}, 'The webbible list should be empty'
|
||||||
|
|
||||||
def test_custom_init(self):
|
def test_custom_init(self):
|
||||||
"""
|
"""
|
||||||
|
@ -53,8 +53,8 @@ class TestBibleHTTP(TestCase):
|
|||||||
books = handler.get_books_from_http('NIV')
|
books = handler.get_books_from_http('NIV')
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# THEN: We should get back a valid service item
|
||||||
self.assertEqual(len(books), 66, 'The bible should not have had any books added or removed')
|
assert len(books) == 66, 'The bible should not have had any books added or removed'
|
||||||
self.assertEqual(books[0], 'Genesis', 'The first bible book should be Genesis')
|
assert books[0] == 'Genesis', 'The first bible book should be Genesis'
|
||||||
|
|
||||||
def test_bible_gateway_extract_books_support_redirect(self):
|
def test_bible_gateway_extract_books_support_redirect(self):
|
||||||
"""
|
"""
|
||||||
@ -67,7 +67,7 @@ class TestBibleHTTP(TestCase):
|
|||||||
books = handler.get_books_from_http('DN1933')
|
books = handler.get_books_from_http('DN1933')
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# THEN: We should get back a valid service item
|
||||||
self.assertEqual(len(books), 66, 'This bible should have 66 books')
|
assert len(books) == 66, 'This bible should have 66 books'
|
||||||
|
|
||||||
def test_bible_gateway_extract_verse(self):
|
def test_bible_gateway_extract_verse(self):
|
||||||
"""
|
"""
|
||||||
@ -80,8 +80,7 @@ class TestBibleHTTP(TestCase):
|
|||||||
results = handler.get_bible_chapter('NIV', 'John', 3)
|
results = handler.get_bible_chapter('NIV', 'John', 3)
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# THEN: We should get back a valid service item
|
||||||
self.assertEqual(len(results.verse_list), 36,
|
assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
|
||||||
'The book of John should not have had any verses added or removed')
|
|
||||||
|
|
||||||
def test_bible_gateway_extract_verse_nkjv(self):
|
def test_bible_gateway_extract_verse_nkjv(self):
|
||||||
"""
|
"""
|
||||||
@ -94,8 +93,7 @@ class TestBibleHTTP(TestCase):
|
|||||||
results = handler.get_bible_chapter('NKJV', 'John', 3)
|
results = handler.get_bible_chapter('NKJV', 'John', 3)
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# THEN: We should get back a valid service item
|
||||||
self.assertEqual(len(results.verse_list), 36,
|
assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
|
||||||
'The book of John should not have had any verses added or removed')
|
|
||||||
|
|
||||||
def test_crosswalk_extract_books(self):
|
def test_crosswalk_extract_books(self):
|
||||||
"""
|
"""
|
||||||
@ -108,7 +106,7 @@ class TestBibleHTTP(TestCase):
|
|||||||
books = handler.get_books_from_http('niv')
|
books = handler.get_books_from_http('niv')
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# THEN: We should get back a valid service item
|
||||||
self.assertEqual(len(books), 66, 'The bible should not have had any books added or removed')
|
assert len(books) == 66, 'The bible should not have had any books added or removed'
|
||||||
|
|
||||||
def test_crosswalk_extract_verse(self):
|
def test_crosswalk_extract_verse(self):
|
||||||
"""
|
"""
|
||||||
@ -121,8 +119,7 @@ class TestBibleHTTP(TestCase):
|
|||||||
results = handler.get_bible_chapter('niv', 'john', 3)
|
results = handler.get_bible_chapter('niv', 'john', 3)
|
||||||
|
|
||||||
# THEN: We should get back a valid service item
|
# THEN: We should get back a valid service item
|
||||||
self.assertEqual(len(results.verse_list), 36,
|
assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
|
||||||
'The book of John should not have had any verses added or removed')
|
|
||||||
|
|
||||||
def test_bibleserver_get_bibles(self):
|
def test_bibleserver_get_bibles(self):
|
||||||
"""
|
"""
|
||||||
@ -135,9 +132,9 @@ class TestBibleHTTP(TestCase):
|
|||||||
bibles = handler.get_bibles_from_http()
|
bibles = handler.get_bibles_from_http()
|
||||||
|
|
||||||
# THEN: The list should not be None, and some known bibles should be there
|
# THEN: The list should not be None, and some known bibles should be there
|
||||||
self.assertIsNotNone(bibles)
|
assert bibles is not None
|
||||||
self.assertIn(('New Int. Readers Version', 'NIRV', 'en'), bibles)
|
assert ('New Int. Readers Version', 'NIRV', 'en') in bibles
|
||||||
self.assertIn(('Священное Писание, Восточный перевод', 'CARS', 'ru'), bibles)
|
assert ('Священное Писание, Восточный перевод', 'CARS', 'ru') in bibles
|
||||||
|
|
||||||
def test_biblegateway_get_bibles(self):
|
def test_biblegateway_get_bibles(self):
|
||||||
"""
|
"""
|
||||||
@ -150,8 +147,8 @@ class TestBibleHTTP(TestCase):
|
|||||||
bibles = handler.get_bibles_from_http()
|
bibles = handler.get_bibles_from_http()
|
||||||
|
|
||||||
# THEN: The list should not be None, and some known bibles should be there
|
# THEN: The list should not be None, and some known bibles should be there
|
||||||
self.assertIsNotNone(bibles)
|
assert bibles is not None
|
||||||
self.assertIn(('Holman Christian Standard Bible (HCSB)', 'HCSB', 'en'), bibles)
|
assert ('Holman Christian Standard Bible (HCSB)', 'HCSB', 'en') in bibles
|
||||||
|
|
||||||
def test_crosswalk_get_bibles(self):
|
def test_crosswalk_get_bibles(self):
|
||||||
"""
|
"""
|
||||||
@ -164,8 +161,8 @@ class TestBibleHTTP(TestCase):
|
|||||||
bibles = handler.get_bibles_from_http()
|
bibles = handler.get_bibles_from_http()
|
||||||
|
|
||||||
# THEN: The list should not be None, and some known bibles should be there
|
# THEN: The list should not be None, and some known bibles should be there
|
||||||
self.assertIsNotNone(bibles)
|
assert bibles is not None
|
||||||
self.assertIn(('Giovanni Diodati 1649 (Italian)', 'gdb', 'it'), bibles)
|
assert ('Giovanni Diodati 1649 (Italian)', 'gdb', 'it') in bibles
|
||||||
|
|
||||||
def test_crosswalk_get_verse_text(self):
|
def test_crosswalk_get_verse_text(self):
|
||||||
"""
|
"""
|
||||||
@ -178,7 +175,6 @@ class TestBibleHTTP(TestCase):
|
|||||||
niv_genesis_chapter_one = handler.get_bible_chapter('niv', 'Genesis', 1)
|
niv_genesis_chapter_one = handler.get_bible_chapter('niv', 'Genesis', 1)
|
||||||
|
|
||||||
# THEN: The verse list should contain the verses
|
# THEN: The verse list should contain the verses
|
||||||
self.assertTrue(niv_genesis_chapter_one.has_verse_list())
|
assert niv_genesis_chapter_one.has_verse_list() is True
|
||||||
self.assertEquals('In the beginning God created the heavens and the earth.',
|
assert 'In the beginning God created the heavens and the earth.' == niv_genesis_chapter_one.verse_list[1], \
|
||||||
niv_genesis_chapter_one.verse_list[1],
|
'The first chapter of genesis should have been fetched.'
|
||||||
'The first chapter of genesis should have been fetched.')
|
|
||||||
|
@ -79,7 +79,7 @@ class TestBibleManager(TestCase, TestMixin):
|
|||||||
# WHEN asking for the books of the bible
|
# WHEN asking for the books of the bible
|
||||||
books = self.manager.get_books('tests')
|
books = self.manager.get_books('tests')
|
||||||
# THEN a list of books should be returned
|
# THEN a list of books should be returned
|
||||||
self.assertEqual(66, len(books), 'There should be 66 books in the bible')
|
assert 66 == len(books), 'There should be 66 books in the bible'
|
||||||
|
|
||||||
def test_get_book_by_id(self):
|
def test_get_book_by_id(self):
|
||||||
"""
|
"""
|
||||||
@ -89,7 +89,7 @@ class TestBibleManager(TestCase, TestMixin):
|
|||||||
# WHEN asking for the book of the bible
|
# WHEN asking for the book of the bible
|
||||||
book = self.manager.get_book_by_id('tests', 54)
|
book = self.manager.get_book_by_id('tests', 54)
|
||||||
# THEN a book should be returned
|
# THEN a book should be returned
|
||||||
self.assertEqual('1 Timothy', book.name, '1 Timothy should have been returned from the bible')
|
assert '1 Timothy' == book.name, '1 Timothy should have been returned from the bible'
|
||||||
|
|
||||||
def test_get_chapter_count(self):
|
def test_get_chapter_count(self):
|
||||||
"""
|
"""
|
||||||
@ -100,7 +100,7 @@ class TestBibleManager(TestCase, TestMixin):
|
|||||||
book = self.manager.get_book_by_id('tests', 54)
|
book = self.manager.get_book_by_id('tests', 54)
|
||||||
chapter = self.manager.get_chapter_count('tests', book)
|
chapter = self.manager.get_chapter_count('tests', book)
|
||||||
# THEN the chapter count should be returned
|
# THEN the chapter count should be returned
|
||||||
self.assertEqual(6, chapter, '1 Timothy should have 6 chapters returned from the bible')
|
assert 6 == chapter, '1 Timothy should have 6 chapters returned from the bible'
|
||||||
|
|
||||||
def test_get_verse_count_by_book_ref_id(self):
|
def test_get_verse_count_by_book_ref_id(self):
|
||||||
"""
|
"""
|
||||||
@ -110,4 +110,4 @@ class TestBibleManager(TestCase, TestMixin):
|
|||||||
# WHEN asking for the number of verses in a book of the bible
|
# WHEN asking for the number of verses in a book of the bible
|
||||||
verses = self.manager.get_verse_count_by_book_ref_id('tests', 54, 3)
|
verses = self.manager.get_verse_count_by_book_ref_id('tests', 54, 3)
|
||||||
# THEN the chapter count should be returned
|
# THEN the chapter count should be returned
|
||||||
self.assertEqual(16, verses, '1 Timothy v3 should have 16 verses returned from the bible')
|
assert 16 == verses, '1 Timothy v3 should have 16 verses returned from the bible'
|
||||||
|
@ -79,7 +79,7 @@ class TestBibleManager(TestCase, TestMixin):
|
|||||||
# WHEN asking to parse the bible reference
|
# WHEN asking to parse the bible reference
|
||||||
results = parse_reference('1 Timothy 1', self.manager.db_cache['tests'], MagicMock(), 54)
|
results = parse_reference('1 Timothy 1', self.manager.db_cache['tests'], MagicMock(), 54)
|
||||||
# THEN a verse array should be returned
|
# THEN a verse array should be returned
|
||||||
self.assertEqual([(54, 1, 1, -1)], results, "The bible verses should matches the expected results")
|
assert [(54, 1, 1, -1)] == results, "The bible verses should matches the expected results"
|
||||||
|
|
||||||
def test_parse_reference_two(self):
|
def test_parse_reference_two(self):
|
||||||
"""
|
"""
|
||||||
@ -89,7 +89,7 @@ class TestBibleManager(TestCase, TestMixin):
|
|||||||
# WHEN asking to parse the bible reference
|
# WHEN asking to parse the bible reference
|
||||||
results = parse_reference('1 Timothy 1:1-2', self.manager.db_cache['tests'], MagicMock(), 54)
|
results = parse_reference('1 Timothy 1:1-2', self.manager.db_cache['tests'], MagicMock(), 54)
|
||||||
# THEN a verse array should be returned
|
# THEN a verse array should be returned
|
||||||
self.assertEqual([(54, 1, 1, 2)], results, "The bible verses should matches the expected results")
|
assert [(54, 1, 1, 2)] == results, "The bible verses should matches the expected results"
|
||||||
|
|
||||||
def test_parse_reference_three(self):
|
def test_parse_reference_three(self):
|
||||||
"""
|
"""
|
||||||
@ -99,8 +99,8 @@ class TestBibleManager(TestCase, TestMixin):
|
|||||||
# WHEN asking to parse the bible reference
|
# WHEN asking to parse the bible reference
|
||||||
results = parse_reference('1 Timothy 1:1-2:1', self.manager.db_cache['tests'], MagicMock(), 54)
|
results = parse_reference('1 Timothy 1:1-2:1', self.manager.db_cache['tests'], MagicMock(), 54)
|
||||||
# THEN a verse array should be returned
|
# THEN a verse array should be returned
|
||||||
self.assertEqual([(54, 1, 1, -1), (54, 2, 1, 1)], results,
|
assert [(54, 1, 1, -1), (54, 2, 1, 1)] == results, \
|
||||||
"The bible verses should match the expected results")
|
"The bible verses should match the expected results"
|
||||||
|
|
||||||
def test_parse_reference_four(self):
|
def test_parse_reference_four(self):
|
||||||
"""
|
"""
|
||||||
@ -110,7 +110,7 @@ class TestBibleManager(TestCase, TestMixin):
|
|||||||
# WHEN asking to parse the bible reference
|
# WHEN asking to parse the bible reference
|
||||||
results = parse_reference('Raoul 1', self.manager.db_cache['tests'], MagicMock())
|
results = parse_reference('Raoul 1', self.manager.db_cache['tests'], MagicMock())
|
||||||
# THEN a verse array should be returned
|
# THEN a verse array should be returned
|
||||||
self.assertEqual([], results, "The bible Search should return an empty list")
|
assert [] == results, "The bible Search should return an empty list"
|
||||||
|
|
||||||
def test_parse_reference_five(self):
|
def test_parse_reference_five(self):
|
||||||
"""
|
"""
|
||||||
@ -120,4 +120,4 @@ class TestBibleManager(TestCase, TestMixin):
|
|||||||
# WHEN asking to parse the bible reference
|
# WHEN asking to parse the bible reference
|
||||||
results = parse_reference('1 Timothy 1:3-end', self.manager.db_cache['tests'], MagicMock(), 54)
|
results = parse_reference('1 Timothy 1:3-end', self.manager.db_cache['tests'], MagicMock(), 54)
|
||||||
# THEN a verse array should be returned
|
# THEN a verse array should be returned
|
||||||
self.assertEqual([(54, 1, 3, -1)], results, "The bible verses should matches the expected results")
|
assert [(54, 1, 3, -1)] == results, "The bible verses should matches the expected results"
|
||||||
|
@ -78,8 +78,8 @@ class TestEditCustomForm(TestCase, TestMixin):
|
|||||||
self.form.load_custom(0)
|
self.form.load_custom(0)
|
||||||
|
|
||||||
# THEN: The line edits should not contain any text.
|
# THEN: The line edits should not contain any text.
|
||||||
self.assertEqual(self.form.title_edit.text(), '', 'The title edit should be empty')
|
assert self.form.title_edit.text() == '', 'The title edit should be empty'
|
||||||
self.assertEqual(self.form.credit_edit.text(), '', 'The credit edit should be empty')
|
assert self.form.credit_edit.text() == '', 'The credit edit should be empty'
|
||||||
|
|
||||||
def test_on_add_button_clicked(self):
|
def test_on_add_button_clicked(self):
|
||||||
"""
|
"""
|
||||||
|
@ -58,9 +58,9 @@ class TestAuthorsForm(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
Test the AuthorForm defaults are correct
|
Test the AuthorForm defaults are correct
|
||||||
"""
|
"""
|
||||||
self.assertEqual(self.form.first_name_edit.text(), '', 'The first name edit should be empty')
|
assert self.form.first_name_edit.text() == '', 'The first name edit should be empty'
|
||||||
self.assertEqual(self.form.last_name_edit.text(), '', 'The last name edit should be empty')
|
assert self.form.last_name_edit.text() == '', 'The last name edit should be empty'
|
||||||
self.assertEqual(self.form.display_edit.text(), '', 'The display name edit should be empty')
|
assert self.form.display_edit.text() == '', 'The display name edit should be empty'
|
||||||
|
|
||||||
def test_get_first_name_property(self):
|
def test_get_first_name_property(self):
|
||||||
"""
|
"""
|
||||||
@ -73,7 +73,7 @@ class TestAuthorsForm(TestCase, TestMixin):
|
|||||||
self.form.first_name_edit.setText(first_name)
|
self.form.first_name_edit.setText(first_name)
|
||||||
|
|
||||||
# THEN: The first_name property should have the correct value
|
# THEN: The first_name property should have the correct value
|
||||||
self.assertEqual(self.form.first_name, first_name, 'The first name property should be correct')
|
assert self.form.first_name == first_name, 'The first name property should be correct'
|
||||||
|
|
||||||
def test_set_first_name_property(self):
|
def test_set_first_name_property(self):
|
||||||
"""
|
"""
|
||||||
@ -86,7 +86,7 @@ class TestAuthorsForm(TestCase, TestMixin):
|
|||||||
self.form.first_name = first_name
|
self.form.first_name = first_name
|
||||||
|
|
||||||
# THEN: The first_name_edit should have the correct value
|
# THEN: The first_name_edit should have the correct value
|
||||||
self.assertEqual(self.form.first_name_edit.text(), first_name, 'The first name should be set correctly')
|
assert self.form.first_name_edit.text() == first_name, 'The first name should be set correctly'
|
||||||
|
|
||||||
def test_get_last_name_property(self):
|
def test_get_last_name_property(self):
|
||||||
"""
|
"""
|
||||||
@ -99,7 +99,7 @@ class TestAuthorsForm(TestCase, TestMixin):
|
|||||||
self.form.last_name_edit.setText(last_name)
|
self.form.last_name_edit.setText(last_name)
|
||||||
|
|
||||||
# THEN: The last_name property should have the correct value
|
# THEN: The last_name property should have the correct value
|
||||||
self.assertEqual(self.form.last_name, last_name, 'The last name property should be correct')
|
assert self.form.last_name == last_name, 'The last name property should be correct'
|
||||||
|
|
||||||
def test_set_last_name_property(self):
|
def test_set_last_name_property(self):
|
||||||
"""
|
"""
|
||||||
@ -112,7 +112,7 @@ class TestAuthorsForm(TestCase, TestMixin):
|
|||||||
self.form.last_name = last_name
|
self.form.last_name = last_name
|
||||||
|
|
||||||
# THEN: The last_name_edit should have the correct value
|
# THEN: The last_name_edit should have the correct value
|
||||||
self.assertEqual(self.form.last_name_edit.text(), last_name, 'The last name should be set correctly')
|
assert self.form.last_name_edit.text() == last_name, 'The last name should be set correctly'
|
||||||
|
|
||||||
def test_get_display_name_property(self):
|
def test_get_display_name_property(self):
|
||||||
"""
|
"""
|
||||||
@ -125,7 +125,7 @@ class TestAuthorsForm(TestCase, TestMixin):
|
|||||||
self.form.display_edit.setText(display_name)
|
self.form.display_edit.setText(display_name)
|
||||||
|
|
||||||
# THEN: The display_name property should have the correct value
|
# THEN: The display_name property should have the correct value
|
||||||
self.assertEqual(self.form.display_name, display_name, 'The display name property should be correct')
|
assert self.form.display_name == display_name, 'The display name property should be correct'
|
||||||
|
|
||||||
def test_set_display_name_property(self):
|
def test_set_display_name_property(self):
|
||||||
"""
|
"""
|
||||||
@ -138,7 +138,7 @@ class TestAuthorsForm(TestCase, TestMixin):
|
|||||||
self.form.display_name = display_name
|
self.form.display_name = display_name
|
||||||
|
|
||||||
# THEN: The display_name_edit should have the correct value
|
# 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')
|
assert self.form.display_edit.text() == display_name, 'The display name should be set correctly'
|
||||||
|
|
||||||
@patch('openlp.plugins.songs.forms.authorsform.QtWidgets.QDialog.exec')
|
@patch('openlp.plugins.songs.forms.authorsform.QtWidgets.QDialog.exec')
|
||||||
def test_exec(self, mocked_exec):
|
def test_exec(self, mocked_exec):
|
||||||
|
@ -69,10 +69,10 @@ class TestEditSongForm(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
Test that the EditSongForm defaults are correct
|
Test that the EditSongForm defaults are correct
|
||||||
"""
|
"""
|
||||||
self.assertFalse(self.form.verse_edit_button.isEnabled(), 'The verse edit button should not be enabled')
|
assert self.form.verse_edit_button.isEnabled() is False, 'The verse edit button should not be enabled'
|
||||||
self.assertFalse(self.form.verse_delete_button.isEnabled(), 'The verse delete button should not be enabled')
|
assert self.form.verse_delete_button.isEnabled() is False, 'The verse delete button should not be enabled'
|
||||||
self.assertFalse(self.form.author_remove_button.isEnabled(), 'The author remove button should not be enabled')
|
assert self.form.author_remove_button.isEnabled() is False, 'The author remove button should not be enabled'
|
||||||
self.assertFalse(self.form.topic_remove_button.isEnabled(), 'The topic remove button should not be enabled')
|
assert self.form.topic_remove_button.isEnabled() is False, 'The topic remove button should not be enabled'
|
||||||
|
|
||||||
def test_is_verse_edit_form_executed(self):
|
def test_is_verse_edit_form_executed(self):
|
||||||
pass
|
pass
|
||||||
@ -147,10 +147,10 @@ class TestEditSongForm(TestCase, TestMixin):
|
|||||||
# GIVEN; Mocked methods
|
# GIVEN; Mocked methods
|
||||||
form = self.form
|
form = self.form
|
||||||
# THEN: CCLI label should be CCLI song label
|
# THEN: CCLI label should be CCLI song label
|
||||||
self.assertNotEquals(form.ccli_label.text(), UiStrings().CCLINumberLabel,
|
assert form.ccli_label.text() is not UiStrings().CCLINumberLabel, \
|
||||||
'CCLI label should not be "{}"'.format(UiStrings().CCLINumberLabel))
|
'CCLI label should not be "{}"'.format(UiStrings().CCLINumberLabel)
|
||||||
self.assertEquals(form.ccli_label.text(), UiStrings().CCLISongNumberLabel,
|
assert form.ccli_label.text() == UiStrings().CCLISongNumberLabel, \
|
||||||
'CCLI label text should be "{}"'.format(UiStrings().CCLISongNumberLabel))
|
'CCLI label text should be "{}"'.format(UiStrings().CCLISongNumberLabel)
|
||||||
|
|
||||||
def test_verse_order_lowercase(self):
|
def test_verse_order_lowercase(self):
|
||||||
"""
|
"""
|
||||||
@ -165,4 +165,4 @@ class TestEditSongForm(TestCase, TestMixin):
|
|||||||
form.on_verse_order_text_changed(form.verse_order_edit.text())
|
form.on_verse_order_text_changed(form.verse_order_edit.text())
|
||||||
|
|
||||||
# THEN: The verse order should be converted to uppercase
|
# THEN: The verse order should be converted to uppercase
|
||||||
self.assertEqual(form.verse_order_edit.text(), 'V1 V2 C1 V3 C1 V4 C1')
|
assert form.verse_order_edit.text() == 'V1 V2 C1 V3 C1 V4 C1'
|
||||||
|
@ -68,7 +68,7 @@ class TestEditVerseForm(TestCase, TestMixin):
|
|||||||
# GIVEN: An EditVerseForm instance
|
# GIVEN: An EditVerseForm instance
|
||||||
# WHEN: The form is shown
|
# WHEN: The form is shown
|
||||||
# THEN: The default value is correct
|
# THEN: The default value is correct
|
||||||
self.assertEqual(self.form.verse_text_edit.toPlainText(), '', 'The verse edit box is empty.')
|
assert self.form.verse_text_edit.toPlainText() == '', 'The verse edit box is empty.'
|
||||||
|
|
||||||
def test_type_verse_text(self):
|
def test_type_verse_text(self):
|
||||||
"""
|
"""
|
||||||
@ -81,8 +81,8 @@ class TestEditVerseForm(TestCase, TestMixin):
|
|||||||
QtTest.QTest.keyClicks(self.form.verse_text_edit, text)
|
QtTest.QTest.keyClicks(self.form.verse_text_edit, text)
|
||||||
|
|
||||||
# THEN: The verse text edit should have the verse text in it
|
# THEN: The verse text edit should have the verse text in it
|
||||||
self.assertEqual(text, self.form.verse_text_edit.toPlainText(),
|
assert text == self.form.verse_text_edit.toPlainText(), \
|
||||||
'The verse text edit should have the typed out verse')
|
'The verse text edit should have the typed out verse'
|
||||||
|
|
||||||
def test_insert_verse(self):
|
def test_insert_verse(self):
|
||||||
"""
|
"""
|
||||||
@ -93,8 +93,8 @@ class TestEditVerseForm(TestCase, TestMixin):
|
|||||||
QtTest.QTest.mouseClick(self.form.insert_button, QtCore.Qt.LeftButton)
|
QtTest.QTest.mouseClick(self.form.insert_button, QtCore.Qt.LeftButton)
|
||||||
|
|
||||||
# THEN: The verse text edit should have a Verse:1 in it
|
# THEN: The verse text edit should have a Verse:1 in it
|
||||||
self.assertIn('---[Verse:1]---', self.form.verse_text_edit.toPlainText(),
|
assert '---[Verse:1]---' in self.form.verse_text_edit.toPlainText(), \
|
||||||
'The verse text edit should have a verse marker')
|
'The verse text edit should have a verse marker'
|
||||||
|
|
||||||
def test_insert_verse_2(self):
|
def test_insert_verse_2(self):
|
||||||
"""
|
"""
|
||||||
@ -106,8 +106,8 @@ class TestEditVerseForm(TestCase, TestMixin):
|
|||||||
QtTest.QTest.mouseClick(self.form.insert_button, QtCore.Qt.LeftButton)
|
QtTest.QTest.mouseClick(self.form.insert_button, QtCore.Qt.LeftButton)
|
||||||
|
|
||||||
# THEN: The verse text edit should have a Verse:1 in it
|
# THEN: The verse text edit should have a Verse:1 in it
|
||||||
self.assertIn('---[Verse:2]---', self.form.verse_text_edit.toPlainText(),
|
assert '---[Verse:2]---' in self.form.verse_text_edit.toPlainText(), \
|
||||||
'The verse text edit should have a "Verse 2" marker')
|
'The verse text edit should have a "Verse 2" marker'
|
||||||
|
|
||||||
def test_insert_chorus(self):
|
def test_insert_chorus(self):
|
||||||
"""
|
"""
|
||||||
@ -119,5 +119,5 @@ class TestEditVerseForm(TestCase, TestMixin):
|
|||||||
QtTest.QTest.mouseClick(self.form.insert_button, QtCore.Qt.LeftButton)
|
QtTest.QTest.mouseClick(self.form.insert_button, QtCore.Qt.LeftButton)
|
||||||
|
|
||||||
# THEN: The verse text edit should have a Chorus:1 in it
|
# THEN: The verse text edit should have a Chorus:1 in it
|
||||||
self.assertIn('---[Chorus:1]---', self.form.verse_text_edit.toPlainText(),
|
assert '---[Chorus:1]---' in self.form.verse_text_edit.toPlainText(), \
|
||||||
'The verse text edit should have a "Chorus 1" marker')
|
'The verse text edit should have a "Chorus 1" marker'
|
||||||
|
@ -57,7 +57,7 @@ class TestTopicsForm(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
Test the TopicsForm defaults are correct
|
Test the TopicsForm defaults are correct
|
||||||
"""
|
"""
|
||||||
self.assertEqual(self.form.name_edit.text(), '', 'The first name edit should be empty')
|
assert self.form.name_edit.text() == '', 'The first name edit should be empty'
|
||||||
|
|
||||||
def test_get_name_property(self):
|
def test_get_name_property(self):
|
||||||
"""
|
"""
|
||||||
@ -70,7 +70,7 @@ class TestTopicsForm(TestCase, TestMixin):
|
|||||||
self.form.name_edit.setText(topic_name)
|
self.form.name_edit.setText(topic_name)
|
||||||
|
|
||||||
# THEN: The name property should have the correct value
|
# THEN: The name property should have the correct value
|
||||||
self.assertEqual(self.form.name, topic_name, 'The name property should be correct')
|
assert self.form.name == topic_name, 'The name property should be correct'
|
||||||
|
|
||||||
def test_set_name_property(self):
|
def test_set_name_property(self):
|
||||||
"""
|
"""
|
||||||
@ -83,4 +83,4 @@ class TestTopicsForm(TestCase, TestMixin):
|
|||||||
self.form.name = topic_name
|
self.form.name = topic_name
|
||||||
|
|
||||||
# THEN: The name_edit should have the correct value
|
# THEN: The name_edit should have the correct value
|
||||||
self.assertEqual(self.form.name_edit.text(), topic_name, 'The topic name should be set correctly')
|
assert self.form.name_edit.text() == topic_name, 'The topic name should be set correctly'
|
||||||
|
@ -52,4 +52,4 @@ class TestBzrTags(TestCase):
|
|||||||
count1 += 1
|
count1 += 1
|
||||||
|
|
||||||
# THEN the tags should match the accepted tags
|
# THEN the tags should match the accepted tags
|
||||||
self.assertEqual(count, count1, 'List of tags should match')
|
assert count == count1, 'List of tags should match'
|
||||||
|
@ -80,7 +80,7 @@ class TestPylint(TestCase):
|
|||||||
print(stderr)
|
print(stderr)
|
||||||
|
|
||||||
# THEN: The output should be empty
|
# THEN: The output should be empty
|
||||||
self.assertTrue(filtered_stdout == '', 'PyLint should find no errors')
|
assert filtered_stdout == '', 'PyLint should find no errors'
|
||||||
|
|
||||||
def _filter_tolerated_errors(self, pylint_output):
|
def _filter_tolerated_errors(self, pylint_output):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user