Fix slide order change when splitting custom slides. Fixes bug 1554748. Fix EasyWorship import issues with missing verses and traceback on unknown chars. Fix traceback in the bug-report dialog. Fixes bug 1554428. Fix weird test bug in test_pluginmanager.py.

This commit is contained in:
Tomas Groth 2016-04-21 21:57:00 +02:00
parent 2c640389f1
commit 895b3bf9b5
5 changed files with 72 additions and 40 deletions

View File

@ -180,11 +180,13 @@ class ExceptionForm(QtWidgets.QDialog, Ui_ExceptionDialog, RegistryProperties):
if ':' in line: if ':' in line:
exception = line.split('\n')[-1].split(':')[0] exception = line.split('\n')[-1].split(':')[0]
subject = 'Bug report: %s in %s' % (exception, source) subject = 'Bug report: %s in %s' % (exception, source)
mail_to_url = QtCore.QUrlQuery('mailto:bugs@openlp.org') mail_urlquery = QtCore.QUrlQuery()
mail_to_url.addQueryItem('subject', subject) mail_urlquery.addQueryItem('subject', subject)
mail_to_url.addQueryItem('body', self.report_text % content) mail_urlquery.addQueryItem('body', self.report_text % content)
if self.file_attachment: if self.file_attachment:
mail_to_url.addQueryItem('attach', self.file_attachment) mail_urlquery.addQueryItem('attach', self.file_attachment)
mail_to_url = QtCore.QUrl('mailto:bugs@openlp.org')
mail_to_url.setQuery(mail_urlquery)
QtGui.QDesktopServices.openUrl(mail_to_url) QtGui.QDesktopServices.openUrl(mail_to_url)
def on_description_updated(self): def on_description_updated(self):

View File

@ -198,6 +198,7 @@ class EditCustomForm(QtWidgets.QDialog, Ui_CustomEditDialog):
# Insert all slides to make the old_slides list complete. # Insert all slides to make the old_slides list complete.
for slide in slides: for slide in slides:
old_slides.insert(old_row, slide) old_slides.insert(old_row, slide)
old_row += 1
self.slide_list_view.addItems(old_slides) self.slide_list_view.addItems(old_slides)
self.slide_list_view.repaint() self.slide_list_view.repaint()

View File

@ -289,6 +289,7 @@ class EasyWorshipSongImport(SongImport):
for i in range(rec_count): for i in range(rec_count):
if self.stop_import_flag: if self.stop_import_flag:
break break
try:
raw_record = db_file.read(record_size) raw_record = db_file.read(record_size)
self.fields = self.record_structure.unpack(raw_record) self.fields = self.record_structure.unpack(raw_record)
self.set_defaults() self.set_defaults()
@ -323,6 +324,10 @@ class EasyWorshipSongImport(SongImport):
self.entry_error_log = '' self.entry_error_log = ''
elif not self.finish(): elif not self.finish():
self.log_error(self.import_source) self.log_error(self.import_source)
except Exception as e:
self.log_error(self.import_source,
translate('SongsPlugin.EasyWorshipSongImport', '"%s" could not be imported. %s')
% (self.title, e))
db_file.close() db_file.close()
self.memo_file.close() self.memo_file.close()
@ -368,7 +373,7 @@ class EasyWorshipSongImport(SongImport):
first_line_is_tag = False first_line_is_tag = False
# EW tags: verse, chorus, pre-chorus, bridge, tag, # EW tags: verse, chorus, pre-chorus, bridge, tag,
# intro, ending, slide # intro, ending, slide
for tag in VerseType.tags + ['tag', 'slide']: for tag in VerseType.names + ['tag', 'slide', 'end']:
tag = tag.lower() tag = tag.lower()
ew_tag = verse_split[0].strip().lower() ew_tag = verse_split[0].strip().lower()
if ew_tag.startswith(tag): if ew_tag.startswith(tag):
@ -390,6 +395,9 @@ class EasyWorshipSongImport(SongImport):
if not number_found: if not number_found:
verse_type += '1' verse_type += '1'
break break
# If the verse only consist of the tag-line, add an empty line to create an empty slide
if first_line_is_tag and len(verse_split) == 1:
verse_split.append("")
self.add_verse(verse_split[-1].strip() if first_line_is_tag else verse, verse_type) self.add_verse(verse_split[-1].strip() if first_line_is_tag else verse, verse_type)
if len(self.comments) > 5: if len(self.comments) > 5:
self.comments += str(translate('SongsPlugin.EasyWorshipSongImport', self.comments += str(translate('SongsPlugin.EasyWorshipSongImport',

View File

@ -32,7 +32,7 @@ from PyQt5 import QtWidgets
from openlp.core.common import Registry, Settings from openlp.core.common import Registry, Settings
from openlp.core.lib.pluginmanager import PluginManager from openlp.core.lib.pluginmanager import PluginManager
from tests.interfaces import MagicMock from tests.interfaces import MagicMock, patch
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
@ -45,13 +45,12 @@ class TestPluginManager(TestCase, TestMixin):
""" """
Some pre-test setup required. Some pre-test setup required.
""" """
Settings.setDefaultFormat(Settings.IniFormat) self.setup_application()
self.build_settings() self.build_settings()
self.temp_dir = mkdtemp('openlp') self.temp_dir = mkdtemp('openlp')
Settings().setValue('advanced/data path', self.temp_dir) Settings().setValue('advanced/data path', self.temp_dir)
Registry.create() Registry.create()
Registry().register('service_list', MagicMock()) Registry().register('service_list', MagicMock())
self.setup_application()
self.main_window = QtWidgets.QMainWindow() self.main_window = QtWidgets.QMainWindow()
Registry().register('main_window', self.main_window) Registry().register('main_window', self.main_window)
@ -64,7 +63,13 @@ class TestPluginManager(TestCase, TestMixin):
gc.collect() gc.collect()
shutil.rmtree(self.temp_dir) shutil.rmtree(self.temp_dir)
def find_plugins_test(self): @patch('openlp.plugins.songusage.lib.db.init_schema')
@patch('openlp.plugins.songs.lib.db.init_schema')
@patch('openlp.plugins.images.lib.db.init_schema')
@patch('openlp.plugins.custom.lib.db.init_schema')
@patch('openlp.plugins.alerts.lib.db.init_schema')
@patch('openlp.plugins.bibles.lib.db.init_schema')
def find_plugins_test(self, mocked_is1, mocked_is2, mocked_is3, mocked_is4, mocked_is5, mocked_is6):
""" """
Test the find_plugins() method to ensure it imports the correct plugins Test the find_plugins() method to ensure it imports the correct plugins
""" """

View File

@ -128,3 +128,19 @@ class TestEditCustomForm(TestCase, TestMixin):
# THEN: The validate method should have returned False. # THEN: The validate method should have returned False.
assert not result, 'The _validate() method should have retured False' assert not result, 'The _validate() method should have retured False'
mocked_critical_error_message_box.assert_called_with(message='You need to add at least one slide.') mocked_critical_error_message_box.assert_called_with(message='You need to add at least one slide.')
def update_slide_list_test(self):
"""
Test the update_slide_list() method
"""
# GIVEN: Mocked slide_list_view with a slide with 3 lines
self.form.slide_list_view = MagicMock()
self.form.slide_list_view.count.return_value = 1
self.form.slide_list_view.currentRow.return_value = 0
self.form.slide_list_view.item.return_value = MagicMock(return_value='1st Slide\n2nd Slide\n3rd Slide')
# WHEN: updating the slide by splitting the lines into slides
self.form.update_slide_list(['1st Slide', '2nd Slide', '3rd Slide'])
# THEN: The slides should be created in correct order
self.form.slide_list_view.addItems.assert_called_with(['1st Slide', '2nd Slide', '3rd Slide'])