forked from openlp/openlp
PEP fixes
This commit is contained in:
parent
14187f4884
commit
6fc1467c5a
@ -79,7 +79,8 @@ class ZefaniaBible(BibleImport):
|
|||||||
chapter_number = CHAPTER.get("cnumber")
|
chapter_number = CHAPTER.get("cnumber")
|
||||||
for VERS in CHAPTER:
|
for VERS in CHAPTER:
|
||||||
verse_number = VERS.get("vnumber")
|
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(
|
self.wizard.increment_progress_bar(
|
||||||
translate('BiblesPlugin.Zefnia',
|
translate('BiblesPlugin.Zefnia',
|
||||||
'Importing {book} {chapter}...').format(book=db_book.name,
|
'Importing {book} {chapter}...').format(book=db_book.name,
|
||||||
|
@ -173,8 +173,8 @@ class TestBibleImport(TestCase):
|
|||||||
# THEN: None should be returned and an error should be logged
|
# THEN: None should be returned and an error should be logged
|
||||||
mocked_languages_get_language.assert_called_once_with('Qwerty')
|
mocked_languages_get_language.assert_called_once_with('Qwerty')
|
||||||
mocked_db_get_language.assert_called_once_with('KJV')
|
mocked_db_get_language.assert_called_once_with('KJV')
|
||||||
self.mocked_log.error.assert_called_once_with('Language detection failed when importing from "KJV". '
|
self.mocked_log.error.assert_called_once_with(
|
||||||
'User aborted language selection.')
|
'Language detection failed when importing from "KJV". User aborted language selection.')
|
||||||
self.assertFalse(instance.save_meta.called)
|
self.assertFalse(instance.save_meta.called)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
@ -418,8 +418,7 @@ class TestBibleImport(TestCase):
|
|||||||
Test that validate_xml_file raises a ValidationError with an Zefania root tag
|
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
|
# GIVEN: Some test data with an Zefania root tag and an instance of BibleImport
|
||||||
with patch.object(BibleImport, 'parse_xml',
|
with patch.object(BibleImport, 'parse_xml', return_value=objectify.fromstring('<xmlbible></xmlbible>')), \
|
||||||
return_value=objectify.fromstring('<xmlbible></xmlbible>')), \
|
|
||||||
patch.object(BibleImport, 'is_compressed', return_value=False):
|
patch.object(BibleImport, 'is_compressed', return_value=False):
|
||||||
importer = BibleImport(MagicMock(), path='.', name='.', filename='')
|
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
|
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
|
# GIVEN: Some test data with an unknown root tag and an instance of BibleImport
|
||||||
with patch.object(BibleImport, 'parse_xml',
|
with patch.object(
|
||||||
return_value=objectify.fromstring('<unknownbible></unknownbible>')), \
|
BibleImport, 'parse_xml', return_value=objectify.fromstring('<unknownbible></unknownbible>')), \
|
||||||
patch.object(BibleImport, 'is_compressed', return_value=False):
|
patch.object(BibleImport, 'is_compressed', return_value=False):
|
||||||
importer = BibleImport(MagicMock(), path='.', name='.', filename='')
|
importer = BibleImport(MagicMock(), path='.', name='.', filename='')
|
||||||
|
|
||||||
|
@ -217,7 +217,8 @@ class TestOpenSongImport(TestCase, TestMixin):
|
|||||||
importer.process_books([book1, book2])
|
importer.process_books([book1, book2])
|
||||||
|
|
||||||
# THEN: find_and_create_book and process_books should be called with the details from the mocked books
|
# 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,
|
self.assertEqual(mocked_process_chapters.call_args_list,
|
||||||
[call('db_book1', 'Chapter1'), call('db_book2', 'Chapter2')])
|
[call('db_book1', 'Chapter1'), call('db_book2', 'Chapter2')])
|
||||||
self.assertEqual(importer.session.commit.call_count, 2)
|
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
|
# GIVEN: An instance of OpenSongBible and a mocked parse_xml which returns False
|
||||||
with patch('openlp.plugins.bibles.lib.importers.opensong.log'), \
|
with patch('openlp.plugins.bibles.lib.importers.opensong.log'), \
|
||||||
patch.object(OpenSongBible, 'validate_xml_file'), \
|
patch.object(OpenSongBible, 'validate_xml_file'), \
|
||||||
patch.object(OpenSongBible, 'parse_xml', return_value=None), \
|
patch.object(OpenSongBible, 'parse_xml', return_value=None), \
|
||||||
patch.object(OpenSongBible, 'get_language_id') as mocked_language_id:
|
patch.object(OpenSongBible, 'get_language_id') as mocked_language_id:
|
||||||
importer = OpenSongBible(MagicMock(), path='.', name='.', filename='')
|
importer = OpenSongBible(MagicMock(), path='.', name='.', filename='')
|
||||||
|
|
||||||
# WHEN: Calling do_import
|
# WHEN: Calling do_import
|
||||||
@ -374,6 +375,7 @@ class TestOpenSongImport(TestCase, TestMixin):
|
|||||||
# THEN: do_import should return True
|
# THEN: do_import should return True
|
||||||
self.assertTrue(result)
|
self.assertTrue(result)
|
||||||
|
|
||||||
|
|
||||||
class TestOpenSongImportFileImports(TestCase, TestMixin):
|
class TestOpenSongImportFileImports(TestCase, TestMixin):
|
||||||
"""
|
"""
|
||||||
Test the functions in the :mod:`opensongimport` module.
|
Test the functions in the :mod:`opensongimport` module.
|
||||||
|
Loading…
Reference in New Issue
Block a user