Merge lp:~tomasgroth/openlp/25bugfixes1 into lp:openlp

Proposed by Tomas Groth
Status: Merged
Approved by: Tomas Groth
Approved revision: 2631
Merged at revision: 2628
Proposed branch: lp:~tomasgroth/openlp/25bugfixes1
Merge into: lp:openlp
Diff against target: 239 lines (+76/-44)
7 files modified
openlp/core/ui/exceptionform.py (+6/-4)
openlp/plugins/custom/forms/editcustomform.py (+1/-0)
openlp/plugins/songs/lib/importers/easyworship.py (+40/-32)
openlp/plugins/songs/lib/mediaitem.py (+2/-2)
tests/functional/openlp_plugins/songs/test_mediaitem.py (+2/-2)
tests/interfaces/openlp_core_lib/test_pluginmanager.py (+9/-4)
tests/interfaces/openlp_plugins/custom/forms/test_customform.py (+16/-0)
To merge this branch: bzr merge lp:~tomasgroth/openlp/25bugfixes1
Reviewer Review Type Date Requested Status
Tim Bentley Approve
Raoul Snyman Approve
Review via email: mp+288872@code.launchpad.net

Description of the change

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.
Pep8 fixes

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) wrote :
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Looks good to me.

review: Approve
Revision history for this message
Tim Bentley (trb143) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/ui/exceptionform.py'
2--- openlp/core/ui/exceptionform.py 2016-01-09 16:26:14 +0000
3+++ openlp/core/ui/exceptionform.py 2016-03-13 22:06:46 +0000
4@@ -180,11 +180,13 @@
5 if ':' in line:
6 exception = line.split('\n')[-1].split(':')[0]
7 subject = 'Bug report: %s in %s' % (exception, source)
8- mail_to_url = QtCore.QUrlQuery('mailto:bugs@openlp.org')
9- mail_to_url.addQueryItem('subject', subject)
10- mail_to_url.addQueryItem('body', self.report_text % content)
11+ mail_urlquery = QtCore.QUrlQuery()
12+ mail_urlquery.addQueryItem('subject', subject)
13+ mail_urlquery.addQueryItem('body', self.report_text % content)
14 if self.file_attachment:
15- mail_to_url.addQueryItem('attach', self.file_attachment)
16+ mail_urlquery.addQueryItem('attach', self.file_attachment)
17+ mail_to_url = QtCore.QUrl('mailto:bugs@openlp.org')
18+ mail_to_url.setQuery(mail_urlquery)
19 QtGui.QDesktopServices.openUrl(mail_to_url)
20
21 def on_description_updated(self):
22
23=== modified file 'openlp/plugins/custom/forms/editcustomform.py'
24--- openlp/plugins/custom/forms/editcustomform.py 2016-01-09 16:26:14 +0000
25+++ openlp/plugins/custom/forms/editcustomform.py 2016-03-13 22:06:46 +0000
26@@ -198,6 +198,7 @@
27 # Insert all slides to make the old_slides list complete.
28 for slide in slides:
29 old_slides.insert(old_row, slide)
30+ old_row += 1
31 self.slide_list_view.addItems(old_slides)
32 self.slide_list_view.repaint()
33
34
35=== modified file 'openlp/plugins/songs/lib/importers/easyworship.py'
36--- openlp/plugins/songs/lib/importers/easyworship.py 2016-01-31 19:36:54 +0000
37+++ openlp/plugins/songs/lib/importers/easyworship.py 2016-03-13 22:06:46 +0000
38@@ -289,40 +289,45 @@
39 for i in range(rec_count):
40 if self.stop_import_flag:
41 break
42- raw_record = db_file.read(record_size)
43- self.fields = self.record_structure.unpack(raw_record)
44- self.set_defaults()
45- self.title = self.get_field(fi_title).decode(self.encoding)
46- # Get remaining fields.
47- copy = self.get_field(fi_copy)
48- admin = self.get_field(fi_admin)
49- ccli = self.get_field(fi_ccli)
50- authors = self.get_field(fi_author)
51- words = self.get_field(fi_words)
52- if copy:
53- self.copyright = copy.decode(self.encoding)
54- if admin:
55+ try:
56+ raw_record = db_file.read(record_size)
57+ self.fields = self.record_structure.unpack(raw_record)
58+ self.set_defaults()
59+ self.title = self.get_field(fi_title).decode(self.encoding)
60+ # Get remaining fields.
61+ copy = self.get_field(fi_copy)
62+ admin = self.get_field(fi_admin)
63+ ccli = self.get_field(fi_ccli)
64+ authors = self.get_field(fi_author)
65+ words = self.get_field(fi_words)
66 if copy:
67- self.copyright += ', '
68- self.copyright += translate('SongsPlugin.EasyWorshipSongImport',
69- 'Administered by %s') % admin.decode(self.encoding)
70- if ccli:
71- self.ccli_number = ccli.decode(self.encoding)
72- if authors:
73- authors = authors.decode(self.encoding)
74- else:
75- authors = ''
76- # Set the SongImport object members.
77- self.set_song_import_object(authors, words)
78- if self.stop_import_flag:
79- break
80- if self.entry_error_log:
81+ self.copyright = copy.decode(self.encoding)
82+ if admin:
83+ if copy:
84+ self.copyright += ', '
85+ self.copyright += translate('SongsPlugin.EasyWorshipSongImport',
86+ 'Administered by %s') % admin.decode(self.encoding)
87+ if ccli:
88+ self.ccli_number = ccli.decode(self.encoding)
89+ if authors:
90+ authors = authors.decode(self.encoding)
91+ else:
92+ authors = ''
93+ # Set the SongImport object members.
94+ self.set_song_import_object(authors, words)
95+ if self.stop_import_flag:
96+ break
97+ if self.entry_error_log:
98+ self.log_error(self.import_source,
99+ translate('SongsPlugin.EasyWorshipSongImport', '"%s" could not be imported. %s')
100+ % (self.title, self.entry_error_log))
101+ self.entry_error_log = ''
102+ elif not self.finish():
103+ self.log_error(self.import_source)
104+ except Exception as e:
105 self.log_error(self.import_source,
106 translate('SongsPlugin.EasyWorshipSongImport', '"%s" could not be imported. %s')
107- % (self.title, self.entry_error_log))
108- self.entry_error_log = ''
109- elif not self.finish():
110- self.log_error(self.import_source)
111+ % (self.title, e))
112 db_file.close()
113 self.memo_file.close()
114
115@@ -368,7 +373,7 @@
116 first_line_is_tag = False
117 # EW tags: verse, chorus, pre-chorus, bridge, tag,
118 # intro, ending, slide
119- for tag in VerseType.tags + ['tag', 'slide']:
120+ for tag in VerseType.names + ['tag', 'slide', 'end']:
121 tag = tag.lower()
122 ew_tag = verse_split[0].strip().lower()
123 if ew_tag.startswith(tag):
124@@ -390,6 +395,9 @@
125 if not number_found:
126 verse_type += '1'
127 break
128+ # If the verse only consist of the tag-line, add an empty line to create an empty slide
129+ if first_line_is_tag and len(verse_split) == 1:
130+ verse_split.append("")
131 self.add_verse(verse_split[-1].strip() if first_line_is_tag else verse, verse_type)
132 if len(self.comments) > 5:
133 self.comments += str(translate('SongsPlugin.EasyWorshipSongImport',
134
135=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
136--- openlp/plugins/songs/lib/mediaitem.py 2016-02-13 16:57:09 +0000
137+++ openlp/plugins/songs/lib/mediaitem.py 2016-03-13 22:06:46 +0000
138@@ -295,7 +295,7 @@
139 :param search_keywords: A list of search keywords - book first, then number
140 :return: None
141 """
142-
143+
144 log.debug('display results Book')
145 self.list_view.clear()
146
147@@ -700,7 +700,7 @@
148 :param s: A string value from the list we want to sort.
149 """
150 return [int(text) if text.isdecimal() else text.lower()
151- for text in re.split('(\d+)', s)]
152+ for text in re.split('(\d+)', s)]
153
154 def search(self, string, show_error):
155 """
156
157=== modified file 'tests/functional/openlp_plugins/songs/test_mediaitem.py'
158--- tests/functional/openlp_plugins/songs/test_mediaitem.py 2016-02-13 16:57:09 +0000
159+++ tests/functional/openlp_plugins/songs/test_mediaitem.py 2016-03-13 22:06:46 +0000
160@@ -422,10 +422,10 @@
161 """
162 # GIVEN: A string to be converted into a sort key
163 string_sort_key = 'A1B12C'
164-
165+
166 # WHEN: We attempt to create a sort key
167 sort_key_result = self.media_item._natural_sort_key(string_sort_key)
168-
169+
170 # THEN: We should get back a tuple split on integers
171 self.assertEqual(sort_key_result, ['a', 1, 'b', 12, 'c'])
172
173
174=== modified file 'tests/interfaces/openlp_core_lib/test_pluginmanager.py'
175--- tests/interfaces/openlp_core_lib/test_pluginmanager.py 2015-12-31 22:46:06 +0000
176+++ tests/interfaces/openlp_core_lib/test_pluginmanager.py 2016-03-13 22:06:46 +0000
177@@ -32,7 +32,7 @@
178
179 from openlp.core.common import Registry, Settings
180 from openlp.core.lib.pluginmanager import PluginManager
181-from tests.interfaces import MagicMock
182+from tests.interfaces import MagicMock, patch
183 from tests.helpers.testmixin import TestMixin
184
185
186@@ -45,13 +45,12 @@
187 """
188 Some pre-test setup required.
189 """
190- Settings.setDefaultFormat(Settings.IniFormat)
191+ self.setup_application()
192 self.build_settings()
193 self.temp_dir = mkdtemp('openlp')
194 Settings().setValue('advanced/data path', self.temp_dir)
195 Registry.create()
196 Registry().register('service_list', MagicMock())
197- self.setup_application()
198 self.main_window = QtWidgets.QMainWindow()
199 Registry().register('main_window', self.main_window)
200
201@@ -64,7 +63,13 @@
202 gc.collect()
203 shutil.rmtree(self.temp_dir)
204
205- def find_plugins_test(self):
206+ @patch('openlp.plugins.songusage.lib.db.init_schema')
207+ @patch('openlp.plugins.songs.lib.db.init_schema')
208+ @patch('openlp.plugins.images.lib.db.init_schema')
209+ @patch('openlp.plugins.custom.lib.db.init_schema')
210+ @patch('openlp.plugins.alerts.lib.db.init_schema')
211+ @patch('openlp.plugins.bibles.lib.db.init_schema')
212+ def find_plugins_test(self, mocked_is1, mocked_is2, mocked_is3, mocked_is4, mocked_is5, mocked_is6):
213 """
214 Test the find_plugins() method to ensure it imports the correct plugins
215 """
216
217=== modified file 'tests/interfaces/openlp_plugins/custom/forms/test_customform.py'
218--- tests/interfaces/openlp_plugins/custom/forms/test_customform.py 2015-12-31 22:46:06 +0000
219+++ tests/interfaces/openlp_plugins/custom/forms/test_customform.py 2016-03-13 22:06:46 +0000
220@@ -128,3 +128,19 @@
221 # THEN: The validate method should have returned False.
222 assert not result, 'The _validate() method should have retured False'
223 mocked_critical_error_message_box.assert_called_with(message='You need to add at least one slide.')
224+
225+ def update_slide_list_test(self):
226+ """
227+ Test the update_slide_list() method
228+ """
229+ # GIVEN: Mocked slide_list_view with a slide with 3 lines
230+ self.form.slide_list_view = MagicMock()
231+ self.form.slide_list_view.count.return_value = 1
232+ self.form.slide_list_view.currentRow.return_value = 0
233+ self.form.slide_list_view.item.return_value = MagicMock(return_value='1st Slide\n2nd Slide\n3rd Slide')
234+
235+ # WHEN: updating the slide by splitting the lines into slides
236+ self.form.update_slide_list(['1st Slide', '2nd Slide', '3rd Slide'])
237+
238+ # THEN: The slides should be created in correct order
239+ self.form.slide_list_view.addItems.assert_called_with(['1st Slide', '2nd Slide', '3rd Slide'])