forked from openlp/openlp
Pep fixes
This commit is contained in:
parent
e67f6dbd94
commit
849bbd2c51
@ -504,7 +504,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.second_combo_box.setCurrentIndex(self.second_combo_box.findData(self.second_bible))
|
self.second_combo_box.setCurrentIndex(self.second_combo_box.findData(self.second_bible))
|
||||||
return
|
return
|
||||||
self.second_bible = new_selection
|
self.second_bible = new_selection
|
||||||
if new_selection == None:
|
if new_selection is None:
|
||||||
self.style_combo_box.setEnabled(True)
|
self.style_combo_box.setEnabled(True)
|
||||||
else:
|
else:
|
||||||
self.style_combo_box.setEnabled(False)
|
self.style_combo_box.setEnabled(False)
|
||||||
@ -669,8 +669,8 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
translate('BiblesPlugin.MediaItem',
|
translate('BiblesPlugin.MediaItem',
|
||||||
'The second Bible "{second_name}" does not contain all the verses that are in the main '
|
'The second Bible "{second_name}" does not contain all the verses that are in the main '
|
||||||
'Bible "{name}".\nOnly verses found in both Bibles will be shown.\n\n'
|
'Bible "{name}".\nOnly verses found in both Bibles will be shown.\n\n'
|
||||||
'{count:d} verses have not been included in the results.')
|
'{count:d} verses have not been included in the results.'
|
||||||
.format(second_name=self.second_bible.name, name=self.bible.name, count=not_found_count))
|
).format(second_name=self.second_bible.name, name=self.bible.name, count=not_found_count))
|
||||||
self.display_results()
|
self.display_results()
|
||||||
|
|
||||||
def text_search(self, search_while_type=False):
|
def text_search(self, search_while_type=False):
|
||||||
@ -707,7 +707,6 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.on_text_search(text)
|
self.on_text_search(text)
|
||||||
self.display_results()
|
self.display_results()
|
||||||
|
|
||||||
|
|
||||||
def on_search_edit_text_changed(self):
|
def on_search_edit_text_changed(self):
|
||||||
"""
|
"""
|
||||||
If 'search_as_you_type' is enabled, start a timer when the search_edit emits a textChanged signal. This is to
|
If 'search_as_you_type' is enabled, start a timer when the search_edit emits a textChanged signal. This is to
|
||||||
|
@ -66,7 +66,7 @@ class TestLib(TestCase, TestMixin):
|
|||||||
Test that the 'full' regex parses bible verse references correctly.
|
Test that the 'full' regex parses bible verse references correctly.
|
||||||
"""
|
"""
|
||||||
# GIVEN: Some test data which contains different references to parse, with the expected results.
|
# GIVEN: Some test data which contains different references to parse, with the expected results.
|
||||||
with patch('openlp.plugins.bibles.lib.Settings', return_value=MagicMock(**{'value.return_value':''})):
|
with patch('openlp.plugins.bibles.lib.Settings', return_value=MagicMock(**{'value.return_value': ''})):
|
||||||
# The following test data tests with 222 variants when using the default 'separators'
|
# The following test data tests with 222 variants when using the default 'separators'
|
||||||
test_data = [
|
test_data = [
|
||||||
# Input reference, book name, chapter + verse reference
|
# Input reference, book name, chapter + verse reference
|
||||||
@ -99,7 +99,7 @@ class TestLib(TestCase, TestMixin):
|
|||||||
verse_separators = [':', ' : ', 'v', ' v ', 'V', ' V ', 'verse', ' verse ', 'verses', ' verses '] \
|
verse_separators = [':', ' : ', 'v', ' v ', 'V', ' V ', 'verse', ' verse ', 'verses', ' verses '] \
|
||||||
if '{verse}' in reference_text else ['']
|
if '{verse}' in reference_text else ['']
|
||||||
and_separators = [',', ' , ', 'and', ' and '] if '{_and}' in reference_text else ['']
|
and_separators = [',', ' , ', 'and', ' and '] if '{_and}' in reference_text else ['']
|
||||||
end_separators = ['end', ' end '] if '{end}' in reference_text else [''];
|
end_separators = ['end', ' end '] if '{end}' in reference_text else ['']
|
||||||
|
|
||||||
for to in to_separators:
|
for to in to_separators:
|
||||||
for verse in verse_separators:
|
for verse in verse_separators:
|
||||||
@ -127,7 +127,7 @@ class TestLib(TestCase, TestMixin):
|
|||||||
see https://bugs.launchpad.net/openlp/+bug/1638620
|
see https://bugs.launchpad.net/openlp/+bug/1638620
|
||||||
"""
|
"""
|
||||||
# GIVEN: Some test data which contains different references to parse, with the expected results.
|
# GIVEN: Some test data which contains different references to parse, with the expected results.
|
||||||
with patch('openlp.plugins.bibles.lib.Settings', return_value=MagicMock(**{'value.return_value':''})):
|
with patch('openlp.plugins.bibles.lib.Settings', return_value=MagicMock(**{'value.return_value': ''})):
|
||||||
# The following test data tests with 45 variants when using the default 'separators'
|
# The following test data tests with 45 variants when using the default 'separators'
|
||||||
test_data = [
|
test_data = [
|
||||||
('23', None, '23', None, None, None),
|
('23', None, '23', None, None, None),
|
||||||
@ -141,7 +141,7 @@ class TestLib(TestCase, TestMixin):
|
|||||||
verse_separators = [':', ' : ', 'v', ' v ', 'V', ' V ', 'verse', ' verse ', 'verses', ' verses '] \
|
verse_separators = [':', ' : ', 'v', ' v ', 'V', ' V ', 'verse', ' verse ', 'verses', ' verses '] \
|
||||||
if '{verse}' in reference_text else ['']
|
if '{verse}' in reference_text else ['']
|
||||||
and_separators = [',', ' , ', 'and', ' and '] if '{_and}' in reference_text else ['']
|
and_separators = [',', ' , ', 'and', ' and '] if '{_and}' in reference_text else ['']
|
||||||
end_separators = ['end', ' end '] if '{end}' in reference_text else [''];
|
end_separators = ['end', ' end '] if '{end}' in reference_text else ['']
|
||||||
|
|
||||||
for to in to_separators:
|
for to in to_separators:
|
||||||
for verse in verse_separators:
|
for verse in verse_separators:
|
||||||
@ -167,8 +167,8 @@ class TestLib(TestCase, TestMixin):
|
|||||||
# The following test data tests with 111 variants when using the default 'separators'
|
# The following test data tests with 111 variants when using the default 'separators'
|
||||||
# The regex for handling ranges is a bit screwy, see https://bugs.launchpad.net/openlp/+bug/1638620
|
# The regex for handling ranges is a bit screwy, see https://bugs.launchpad.net/openlp/+bug/1638620
|
||||||
test_data = [
|
test_data = [
|
||||||
('23',['23']),
|
('23', ['23']),
|
||||||
('23{to}24',['23-24']),
|
('23{to}24', ['23-24']),
|
||||||
('23{verse}1{to}2', ['23:1-2']),
|
('23{verse}1{to}2', ['23:1-2']),
|
||||||
('23{verse}1{to}{end}', ['23:1-end']),
|
('23{verse}1{to}{end}', ['23:1-end']),
|
||||||
('23{verse}1{to}2{_and}5{to}6', ['23:1-2', '5-6']),
|
('23{verse}1{to}2{_and}5{to}6', ['23:1-2', '5-6']),
|
||||||
@ -183,7 +183,7 @@ class TestLib(TestCase, TestMixin):
|
|||||||
verse_separators = [':', ' : ', 'v', ' v ', 'V', ' V ', 'verse', ' verse ', 'verses', ' verses '] \
|
verse_separators = [':', ' : ', 'v', ' v ', 'V', ' V ', 'verse', ' verse ', 'verses', ' verses '] \
|
||||||
if '{verse}' in reference_text else ['']
|
if '{verse}' in reference_text else ['']
|
||||||
and_separators = [',', ' , ', 'and', ' and '] if '{_and}' in reference_text else ['']
|
and_separators = [',', ' , ', 'and', ' and '] if '{_and}' in reference_text else ['']
|
||||||
end_separators = ['end', ' end '] if '{end}' in reference_text else [''];
|
end_separators = ['end', ' end '] if '{end}' in reference_text else ['']
|
||||||
|
|
||||||
for to in to_separators:
|
for to in to_separators:
|
||||||
for verse in verse_separators:
|
for verse in verse_separators:
|
||||||
|
@ -68,7 +68,7 @@ class TestBibleMediaItemModulefunctions(TestCase):
|
|||||||
|
|
||||||
# THEN: The result should contain the 'verse', 'range', 'list' keys and get_reference_separator should have
|
# THEN: The result should contain the 'verse', 'range', 'list' keys and get_reference_separator should have
|
||||||
# been called with the expected values.
|
# been called with the expected values.
|
||||||
self.assertTrue(all (key in result for key in ('verse', 'range', 'list')))
|
self.assertTrue(all(key in result for key in ('verse', 'range', 'list')))
|
||||||
mocked_get_reference_separator.assert_has_calls(
|
mocked_get_reference_separator.assert_has_calls(
|
||||||
[call('sep_v_display'), call('sep_r_display'), call('sep_l_display')])
|
[call('sep_v_display'), call('sep_r_display'), call('sep_l_display')])
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
|
|
||||||
Registry.create()
|
Registry.create()
|
||||||
|
|
||||||
#self.setup_application()
|
# self.setup_application()
|
||||||
self.mocked_application = MagicMock()
|
self.mocked_application = MagicMock()
|
||||||
Registry().register('application', self.mocked_application)
|
Registry().register('application', self.mocked_application)
|
||||||
self.mocked_main_window = MagicMock()
|
self.mocked_main_window = MagicMock()
|
||||||
@ -156,8 +156,6 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
self.mocked_bible_2 = MagicMock(**{'get_books.return_value': self.book_list_2})
|
self.mocked_bible_2 = MagicMock(**{'get_books.return_value': self.book_list_2})
|
||||||
self.mocked_bible_2.name = 'Bible 2'
|
self.mocked_bible_2.name = 'Bible 2'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_media_item_instance(self):
|
def test_media_item_instance(self):
|
||||||
"""
|
"""
|
||||||
When creating an instance of C test that it is also an instance of
|
When creating an instance of C test that it is also an instance of
|
||||||
@ -266,7 +264,8 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
# GIVEN: An instance of :class:`MediaManagerItem` and mocked out settings class with known values
|
# GIVEN: An instance of :class:`MediaManagerItem` and mocked out settings class with known values
|
||||||
self.setting_values = {'bibles/reset to combined quick search': False}
|
self.setting_values = {'bibles/reset to combined quick search': False}
|
||||||
with patch.object(self.media_item, 'populate_bible_combo_boxes'), patch.object(self.media_item, 'config_update'):
|
with patch.object(self.media_item, 'populate_bible_combo_boxes'), \
|
||||||
|
patch.object(self.media_item, 'config_update'):
|
||||||
self.media_item.search_edit = MagicMock()
|
self.media_item.search_edit = MagicMock()
|
||||||
|
|
||||||
# WHEN: Calling initialise()
|
# WHEN: Calling initialise()
|
||||||
@ -282,7 +281,8 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
# GIVEN: An instance of :class:`MediaManagerItem` and mocked out settings class with known values
|
# GIVEN: An instance of :class:`MediaManagerItem` and mocked out settings class with known values
|
||||||
self.setting_values = {'bibles/reset to combined quick search': True}
|
self.setting_values = {'bibles/reset to combined quick search': True}
|
||||||
with patch.object(self.media_item, 'populate_bible_combo_boxes'), patch.object(self.media_item, 'config_update'):
|
with patch.object(self.media_item, 'populate_bible_combo_boxes'), \
|
||||||
|
patch.object(self.media_item, 'config_update'):
|
||||||
self.media_item.search_edit = MagicMock()
|
self.media_item.search_edit = MagicMock()
|
||||||
|
|
||||||
# WHEN: Calling initialise()
|
# WHEN: Calling initialise()
|
||||||
@ -375,7 +375,7 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
# GIVEN: An instance of :class:`MediaManagerItem` and a mocked_book_combo_box which simulates data being found
|
# GIVEN: An instance of :class:`MediaManagerItem` and a mocked_book_combo_box which simulates data being found
|
||||||
# in the list
|
# in the list
|
||||||
self.media_item.select_book_combo_box = MagicMock(**{'findData.return_value':2})
|
self.media_item.select_book_combo_box = MagicMock(**{'findData.return_value': 2})
|
||||||
with patch.object(self.media_item, 'get_common_books', return_value=self.book_list_1), \
|
with patch.object(self.media_item, 'get_common_books', return_value=self.book_list_1), \
|
||||||
patch.object(self.media_item, 'on_advanced_book_combo_box'):
|
patch.object(self.media_item, 'on_advanced_book_combo_box'):
|
||||||
|
|
||||||
@ -394,7 +394,7 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
# GIVEN: An instance of :class:`MediaManagerItem` and a mocked_book_combo_box which simulates data not being
|
# GIVEN: An instance of :class:`MediaManagerItem` and a mocked_book_combo_box which simulates data not being
|
||||||
# found in the list
|
# found in the list
|
||||||
self.media_item.select_book_combo_box = MagicMock(**{'findData.return_value':-1})
|
self.media_item.select_book_combo_box = MagicMock(**{'findData.return_value': -1})
|
||||||
with patch.object(self.media_item, 'get_common_books', return_value=self.book_list_1), \
|
with patch.object(self.media_item, 'get_common_books', return_value=self.book_list_1), \
|
||||||
patch.object(self.media_item, 'on_advanced_book_combo_box'):
|
patch.object(self.media_item, 'on_advanced_book_combo_box'):
|
||||||
|
|
||||||
@ -460,6 +460,7 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
patch('openlp.plugins.bibles.lib.mediaitem.get_locale_key', side_effect=lambda x: x), \
|
patch('openlp.plugins.bibles.lib.mediaitem.get_locale_key', side_effect=lambda x: x), \
|
||||||
patch('openlp.plugins.bibles.lib.mediaitem.set_case_insensitive_completer') \
|
patch('openlp.plugins.bibles.lib.mediaitem.set_case_insensitive_completer') \
|
||||||
as mocked_set_case_insensitive_completer:
|
as mocked_set_case_insensitive_completer:
|
||||||
|
|
||||||
# WHEN: Calling update_auto_completer
|
# WHEN: Calling update_auto_completer
|
||||||
self.media_item.update_auto_completer()
|
self.media_item.update_auto_completer()
|
||||||
|
|
||||||
@ -723,7 +724,6 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
self.media_item.settings.layout_style_combo_box.setCurrentIndex.assert_called_once_with(2)
|
self.media_item.settings.layout_style_combo_box.setCurrentIndex.assert_called_once_with(2)
|
||||||
self.mocked_settings_instance.setValue.assert_called_once_with('bibles/verse layout style', 2)
|
self.mocked_settings_instance.setValue.assert_called_once_with('bibles/verse layout style', 2)
|
||||||
|
|
||||||
|
|
||||||
def test_on_version_combo_box_index_changed_no_bible(self):
|
def test_on_version_combo_box_index_changed_no_bible(self):
|
||||||
"""
|
"""
|
||||||
Test on_version_combo_box_index_changed when there is no main bible.
|
Test on_version_combo_box_index_changed when there is no main bible.
|
||||||
@ -746,7 +746,7 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
# GIVEN: An instance of :class:`MediaManagerItem` and mocked media_item.settings and select_book_combo_box
|
# GIVEN: An instance of :class:`MediaManagerItem` and mocked media_item.settings and select_book_combo_box
|
||||||
mocked_bible_db = MagicMock()
|
mocked_bible_db = MagicMock()
|
||||||
mocked_bible_db.name='ABC'
|
mocked_bible_db.name = 'ABC'
|
||||||
self.media_item.version_combo_box = MagicMock(**{'currentData.return_value': mocked_bible_db})
|
self.media_item.version_combo_box = MagicMock(**{'currentData.return_value': mocked_bible_db})
|
||||||
self.media_item.select_book_combo_box = MagicMock()
|
self.media_item.select_book_combo_box = MagicMock()
|
||||||
with patch.object(self.media_item, 'initialise_advanced_bible') as mocked_initialise_advanced_bible:
|
with patch.object(self.media_item, 'initialise_advanced_bible') as mocked_initialise_advanced_bible:
|
||||||
@ -781,7 +781,6 @@ class TestMediaItem(TestCase, TestMixin):
|
|||||||
self.media_item.style_combo_box.setEnabled.assert_called_once_with(False)
|
self.media_item.style_combo_box.setEnabled.assert_called_once_with(False)
|
||||||
self.assertEqual(self.media_item.second_bible, self.mocked_bible_2)
|
self.assertEqual(self.media_item.second_bible, self.mocked_bible_2)
|
||||||
|
|
||||||
|
|
||||||
def test_on_second_combo_box_index_changed_single_to_dual_user_abort(self):
|
def test_on_second_combo_box_index_changed_single_to_dual_user_abort(self):
|
||||||
"""
|
"""
|
||||||
Test on_second_combo_box_index_changed when the user changes from single to dual bible mode, there are search
|
Test on_second_combo_box_index_changed when the user changes from single to dual bible mode, there are search
|
||||||
|
Loading…
Reference in New Issue
Block a user