PEP fixes

This commit is contained in:
Philip Ridout 2016-09-02 15:32:14 +01:00
parent 14187f4884
commit 6fc1467c5a
3 changed files with 13 additions and 11 deletions

View File

@ -79,7 +79,8 @@ class ZefaniaBible(BibleImport):
chapter_number = CHAPTER.get("cnumber")
for VERS in CHAPTER:
verse_number = VERS.get("vnumber")
self.create_verse(db_book.id, int(chapter_number), int(verse_number), VERS.text.replace('<BR/>', '\n'))
self.create_verse(
db_book.id, int(chapter_number), int(verse_number), VERS.text.replace('<BR/>', '\n'))
self.wizard.increment_progress_bar(
translate('BiblesPlugin.Zefnia',
'Importing {book} {chapter}...').format(book=db_book.name,

View File

@ -173,8 +173,8 @@ class TestBibleImport(TestCase):
# THEN: None should be returned and an error should be logged
mocked_languages_get_language.assert_called_once_with('Qwerty')
mocked_db_get_language.assert_called_once_with('KJV')
self.mocked_log.error.assert_called_once_with('Language detection failed when importing from "KJV". '
'User aborted language selection.')
self.mocked_log.error.assert_called_once_with(
'Language detection failed when importing from "KJV". User aborted language selection.')
self.assertFalse(instance.save_meta.called)
self.assertIsNone(result)
@ -418,8 +418,7 @@ class TestBibleImport(TestCase):
Test that validate_xml_file raises a ValidationError with an Zefania root tag
"""
# GIVEN: Some test data with an Zefania root tag and an instance of BibleImport
with patch.object(BibleImport, 'parse_xml',
return_value=objectify.fromstring('<xmlbible></xmlbible>')), \
with patch.object(BibleImport, 'parse_xml', return_value=objectify.fromstring('<xmlbible></xmlbible>')), \
patch.object(BibleImport, 'is_compressed', return_value=False):
importer = BibleImport(MagicMock(), path='.', name='.', filename='')
@ -437,8 +436,8 @@ class TestBibleImport(TestCase):
Test that validate_xml_file raises a ValidationError with an unknown root tag
"""
# GIVEN: Some test data with an unknown root tag and an instance of BibleImport
with patch.object(BibleImport, 'parse_xml',
return_value=objectify.fromstring('<unknownbible></unknownbible>')), \
with patch.object(
BibleImport, 'parse_xml', return_value=objectify.fromstring('<unknownbible></unknownbible>')), \
patch.object(BibleImport, 'is_compressed', return_value=False):
importer = BibleImport(MagicMock(), path='.', name='.', filename='')

View File

@ -217,7 +217,8 @@ class TestOpenSongImport(TestCase, TestMixin):
importer.process_books([book1, book2])
# THEN: find_and_create_book and process_books should be called with the details from the mocked books
self.assertEqual(self.mocked_find_and_create_book.call_args_list, [call('Name1', 2, 10), call('Name2', 2, 10)])
self.assertEqual(self.mocked_find_and_create_book.call_args_list,
[call('Name1', 2, 10), call('Name2', 2, 10)])
self.assertEqual(mocked_process_chapters.call_args_list,
[call('db_book1', 'Chapter1'), call('db_book2', 'Chapter2')])
self.assertEqual(importer.session.commit.call_count, 2)
@ -325,9 +326,9 @@ class TestOpenSongImport(TestCase, TestMixin):
"""
# GIVEN: An instance of OpenSongBible and a mocked parse_xml which returns False
with patch('openlp.plugins.bibles.lib.importers.opensong.log'), \
patch.object(OpenSongBible, 'validate_xml_file'), \
patch.object(OpenSongBible, 'parse_xml', return_value=None), \
patch.object(OpenSongBible, 'get_language_id') as mocked_language_id:
patch.object(OpenSongBible, 'validate_xml_file'), \
patch.object(OpenSongBible, 'parse_xml', return_value=None), \
patch.object(OpenSongBible, 'get_language_id') as mocked_language_id:
importer = OpenSongBible(MagicMock(), path='.', name='.', filename='')
# WHEN: Calling do_import
@ -374,6 +375,7 @@ class TestOpenSongImport(TestCase, TestMixin):
# THEN: do_import should return True
self.assertTrue(result)
class TestOpenSongImportFileImports(TestCase, TestMixin):
"""
Test the functions in the :mod:`opensongimport` module.