mirror of https://gitlab.com/openlp/openlp.git
- Merged trunk and fixed conflict.
This commit is contained in:
commit
a7b4d001c7
|
@ -97,9 +97,9 @@ class Ui_ExceptionDialog(object):
|
|||
translate('OpenLP.ExceptionDialog', '<strong>Please describe what you were trying to do.</strong> '
|
||||
' If possible, write in English.'))
|
||||
exception_part1 = (translate('OpenLP.ExceptionDialog',
|
||||
'<strong>Oops, OpenLP hit a problem and couldn\'t recover!</strong> <br><br>'
|
||||
'<strong>You can help </strong> the OpenLP developers to <strong>fix this</strong>'
|
||||
' by<br> sending them a <strong>bug report</strong> to {email}{newlines}'
|
||||
'<strong>Oops, OpenLP hit a problem and couldn\'t recover!<br><br>'
|
||||
'You can help </strong> the OpenLP developers to <strong>fix this</strong>'
|
||||
' by<br> sending them a <strong>bug report to {email}</strong>{newlines}'
|
||||
).format(email='<a href = "mailto:bugs@openlp.org" > bugs@openlp.org</a>',
|
||||
newlines='<br><br>'))
|
||||
self.message_label.setText(
|
||||
|
|
|
@ -493,7 +493,7 @@ class CWExtract(RegistryProperties):
|
|||
for verse in verses_div:
|
||||
self.application.process_events()
|
||||
verse_number = int(verse.find('strong').contents[0])
|
||||
verse_span = verse.find('span')
|
||||
verse_span = verse.find('span', class_='verse-%d' % verse_number)
|
||||
tags_to_remove = verse_span.find_all(['a', 'sup'])
|
||||
for tag in tags_to_remove:
|
||||
tag.decompose()
|
||||
|
|
|
@ -367,7 +367,6 @@ class BibleManager(OpenLPMixin, RegistryProperties):
|
|||
second_web_bible = self.db_cache[second_bible].get_object(BibleMeta, 'download_source')
|
||||
if web_bible or second_web_bible:
|
||||
# If either Bible is Web, cursor is reset to normal and search ends w/o any message.
|
||||
self.check_search_result()
|
||||
self.application.set_normal_cursor()
|
||||
return None
|
||||
# Fetch the results from db. If no results are found, return None, no message is given for this.
|
||||
|
|
|
@ -254,8 +254,8 @@ class BibleMediaItem(MediaManagerItem):
|
|||
self.quickStyleComboBox.activated.connect(self.on_quick_style_combo_box_changed)
|
||||
self.advancedStyleComboBox.activated.connect(self.on_advanced_style_combo_box_changed)
|
||||
# Buttons
|
||||
self.advancedClearButton.clicked.connect(self.on_clear_button)
|
||||
self.quickClearButton.clicked.connect(self.on_clear_button)
|
||||
self.advancedClearButton.clicked.connect(self.on_advanced_clear_button_clicked)
|
||||
self.quickClearButton.clicked.connect(self.on_clear_button_clicked)
|
||||
self.advancedSearchButton.clicked.connect(self.on_advanced_search_button)
|
||||
self.quickSearchButton.clicked.connect(self.on_quick_search_button)
|
||||
# Other stuff
|
||||
|
@ -548,19 +548,31 @@ class BibleMediaItem(MediaManagerItem):
|
|||
self.advancedTab.setVisible(True)
|
||||
self.advanced_book_combo_box.setFocus()
|
||||
|
||||
def on_clear_button(self):
|
||||
def on_clear_button_clicked(self):
|
||||
# Clear the list, then set the "No search Results" message, then clear the text field and give it focus.
|
||||
self.list_view.clear()
|
||||
self.check_search_result()
|
||||
self.quick_search_edit.clear()
|
||||
self.quick_search_edit.setFocus()
|
||||
|
||||
def on_advanced_clear_button_clicked(self):
|
||||
# The same as the on_clear_button_clicked, but gives focus to Book name field in "Select" (advanced).
|
||||
self.list_view.clear()
|
||||
self.check_search_result()
|
||||
self.advanced_book_combo_box.setFocus()
|
||||
|
||||
def on_lock_button_toggled(self, checked):
|
||||
self.quick_search_edit.setFocus()
|
||||
"""
|
||||
Toggle the lock button, if Search tab is used, set focus to search field.
|
||||
:param checked: The state of the toggle button. bool
|
||||
:return: None
|
||||
"""
|
||||
if checked:
|
||||
self.sender().setIcon(self.lock_icon)
|
||||
else:
|
||||
self.sender().setIcon(self.unlock_icon)
|
||||
if self.quickTab.isVisible():
|
||||
self.quick_search_edit.setFocus()
|
||||
|
||||
def on_quick_style_combo_box_changed(self):
|
||||
self.settings.layout_style = self.quickStyleComboBox.currentIndex()
|
||||
|
|
|
@ -101,7 +101,7 @@ class MediaShoutImport(SongImport):
|
|||
self.song_book_name = song.SongID
|
||||
for verse in verses:
|
||||
tag = VERSE_TAGS[verse.Type] + str(verse.Number) if verse.Type < len(VERSE_TAGS) else 'O'
|
||||
self.add_verse(verse.Text, tag)
|
||||
self.add_verse(self.tidy_text(verse.Text), tag)
|
||||
for order in verse_order:
|
||||
if order.Type < len(VERSE_TAGS):
|
||||
self.verse_order_list.append(VERSE_TAGS[order.Type] + str(order.Number))
|
||||
|
|
|
@ -140,10 +140,13 @@ class SongImport(QtCore.QObject):
|
|||
text = text.replace('\u2026', '...')
|
||||
text = text.replace('\u2013', '-')
|
||||
text = text.replace('\u2014', '-')
|
||||
# Replace vertical tab with 2 linebreaks
|
||||
text = text.replace('\v', '\n\n')
|
||||
# Replace form feed (page break) with 2 linebreaks
|
||||
text = text.replace('\f', '\n\n')
|
||||
# Remove surplus blank lines, spaces, trailing/leading spaces
|
||||
text = re.sub(r'[ \t\v]+', ' ', text)
|
||||
text = re.sub(r'[ \t]+', ' ', text)
|
||||
text = re.sub(r' ?(\r\n?|\n) ?', '\n', text)
|
||||
text = re.sub(r' ?(\n{5}|\f)+ ?', '\f', text)
|
||||
return text
|
||||
|
||||
def process_song_text(self, text):
|
||||
|
|
|
@ -135,7 +135,7 @@ class TestMediaItem(TestCase, TestMixin):
|
|||
self.assertTrue(self.media_item.has_delete_icon, 'Check that the icon is called as True.')
|
||||
self.assertFalse(self.media_item.add_to_service_item, 'Check that the icon is called as False')
|
||||
|
||||
def on_quick_search_button_general_test(self):
|
||||
def test_on_quick_search_button_general(self):
|
||||
"""
|
||||
Test that general things, which should be called on all Quick searches are called.
|
||||
"""
|
||||
|
@ -171,3 +171,60 @@ class TestMediaItem(TestCase, TestMixin):
|
|||
self.assertEqual(2, self.media_item.quickSearchButton.setEnabled.call_count, 'Disable and Enable the button')
|
||||
self.assertEqual(1, self.media_item.check_search_result.call_count, 'Check results Should had been called once')
|
||||
self.assertEqual(1, self.app.set_normal_cursor.call_count, 'Normal cursor should had been called once')
|
||||
|
||||
def test_on_clear_button_clicked(self):
|
||||
"""
|
||||
Test that the on_clear_button_clicked works properly. (Used by Bible search tab)
|
||||
"""
|
||||
# GIVEN: Mocked list_view, check_search_results & quick_search_edit.
|
||||
self.media_item.list_view = MagicMock()
|
||||
self.media_item.check_search_result = MagicMock()
|
||||
self.media_item.quick_search_edit = MagicMock()
|
||||
|
||||
# WHEN: on_clear_button_clicked is called
|
||||
self.media_item.on_clear_button_clicked()
|
||||
|
||||
# THEN: Search result should be reset and search field should receive focus.
|
||||
self.media_item.list_view.clear.assert_called_once_with(),
|
||||
self.media_item.check_search_result.assert_called_once_with(),
|
||||
self.media_item.quick_search_edit.clear.assert_called_once_with(),
|
||||
self.media_item.quick_search_edit.setFocus.assert_called_once_with()
|
||||
|
||||
def test_on_lock_button_toggled_search_tab_lock_icon(self):
|
||||
"""
|
||||
Test that "on_lock_button_toggled" gives focus to the right field and toggles the lock properly.
|
||||
"""
|
||||
# GIVEN: Mocked sender & Search edit, quickTab returning value = True on isVisible.
|
||||
self.media_item.sender = MagicMock()
|
||||
self.media_item.quick_search_edit = MagicMock()
|
||||
self.media_item.quickTab = MagicMock(**{'isVisible.return_value': True})
|
||||
|
||||
self.media_item.lock_icon = 'lock icon'
|
||||
sender_instance_mock = MagicMock()
|
||||
self.media_item.sender = MagicMock(return_value=sender_instance_mock)
|
||||
|
||||
# WHEN: on_lock_button_toggled is called and checked returns = True.
|
||||
self.media_item.on_lock_button_toggled(True)
|
||||
|
||||
# THEN: on_quick_search_edit should receive focus and Lock icon should be set.
|
||||
self.media_item.quick_search_edit.setFocus.assert_called_once_with()
|
||||
sender_instance_mock.setIcon.assert_called_once_with('lock icon')
|
||||
|
||||
def test_on_lock_button_toggled_unlock_icon(self):
|
||||
"""
|
||||
Test that lock button unlocks properly and lock toggles properly.
|
||||
"""
|
||||
# GIVEN: Mocked sender & Search edit, quickTab returning value = False on isVisible.
|
||||
self.media_item.sender = MagicMock()
|
||||
self.media_item.quick_search_edit = MagicMock()
|
||||
self.media_item.quickTab = MagicMock()
|
||||
self.media_item.quickTab.isVisible = MagicMock()
|
||||
self.media_item.unlock_icon = 'unlock icon'
|
||||
sender_instance_mock = MagicMock()
|
||||
self.media_item.sender = MagicMock(return_value=sender_instance_mock)
|
||||
|
||||
# WHEN: on_lock_button_toggled is called and checked returns = False.
|
||||
self.media_item.on_lock_button_toggled(False)
|
||||
|
||||
# THEN: Unlock icon should be set.
|
||||
sender_instance_mock.setIcon.assert_called_once_with('unlock icon')
|
||||
|
|
|
@ -22,15 +22,20 @@
|
|||
"""
|
||||
Test the MediaShout importer
|
||||
"""
|
||||
from unittest import TestCase
|
||||
from unittest import TestCase, skipUnless
|
||||
from collections import namedtuple
|
||||
|
||||
from openlp.core.common import Registry
|
||||
from openlp.plugins.songs.lib.importers.mediashout import MediaShoutImport
|
||||
try:
|
||||
from openlp.plugins.songs.lib.importers.mediashout import MediaShoutImport
|
||||
CAN_RUN_TESTS = True
|
||||
except ImportError:
|
||||
CAN_RUN_TESTS = False
|
||||
|
||||
from tests.functional import MagicMock, patch, call
|
||||
|
||||
|
||||
@skipUnless(CAN_RUN_TESTS, 'Not Windows, skipping test')
|
||||
class TestMediaShoutImport(TestCase):
|
||||
"""
|
||||
Test the MediaShout importer
|
||||
|
|
|
@ -163,3 +163,19 @@ class TestBibleHTTP(TestCase):
|
|||
# THEN: The list should not be None, and some known bibles should be there
|
||||
self.assertIsNotNone(bibles)
|
||||
self.assertIn(('Giovanni Diodati 1649 (Italian)', 'gdb', 'it'), bibles)
|
||||
|
||||
def test_crosswalk_get_verse_text(self):
|
||||
"""
|
||||
Test verse text from Crosswalk.com
|
||||
"""
|
||||
# GIVEN: A new Crosswalk extraction class
|
||||
handler = CWExtract()
|
||||
|
||||
# WHEN: downloading NIV Genesis from Crosswalk
|
||||
niv_genesis_chapter_one = handler.get_bible_chapter('niv', 'Genesis', 1)
|
||||
|
||||
# THEN: The verse list should contain the verses
|
||||
self.assertTrue(niv_genesis_chapter_one.has_verse_list())
|
||||
self.assertEquals('In the beginning God created the heavens and the earth.',
|
||||
niv_genesis_chapter_one.verse_list[1],
|
||||
'The first chapter of genesis should have been fetched.')
|
||||
|
|
Loading…
Reference in New Issue