Merge lp:~tomasgroth/openlp/importer-fixes into lp:openlp

Proposed by Tomas Groth on 2016-01-09
Status: Merged
Approved by: Tomas Groth on 2016-01-09
Approved revision: 2598
Merged at revision: 2595
Proposed branch: lp:~tomasgroth/openlp/importer-fixes
Merge into: lp:openlp
Diff against target: 728 lines (+340/-67)
22 files modified
openlp/core/common/settings.py (+6/-3)
openlp/core/ui/maindisplay.py (+4/-3)
openlp/core/ui/themeform.py (+1/-1)
openlp/plugins/custom/lib/mediaitem.py (+1/-1)
openlp/plugins/songs/lib/importer.py (+17/-17)
openlp/plugins/songs/lib/importers/easyslides.py (+6/-9)
openlp/plugins/songs/lib/importers/sundayplus.py (+28/-24)
openlp/plugins/songs/lib/importers/videopsalm.py (+0/-1)
tests/functional/openlp_core_lib/test_mediamanageritem.py (+0/-1)
tests/functional/openlp_core_lib/test_projectordb.py (+0/-1)
tests/functional/openlp_plugins/songs/test_easyslidesimport.py (+45/-0)
tests/functional/openlp_plugins/songs/test_songformat.py (+0/-1)
tests/functional/openlp_plugins/songs/test_sundayplusimport.py (+51/-0)
tests/functional/openlp_plugins/songs/test_videopsalm.py (+0/-1)
tests/helpers/testmixin.py (+6/-2)
tests/interfaces/openlp_core_ui/test_projectoreditform.py (+0/-2)
tests/resources/easyslidessongs/Amazing Grace.json (+32/-0)
tests/resources/easyslidessongs/amazing-grace.xml (+53/-0)
tests/resources/sundayplussongs/Abba Fader.ptf (+8/-0)
tests/resources/sundayplussongs/Amazing Grace.json (+26/-0)
tests/resources/sundayplussongs/Amazing Grace.ptf (+43/-0)
tests/resources/sundayplussongs/abba-fader.json (+13/-0)
To merge this branch: bzr merge lp:~tomasgroth/openlp/importer-fixes
Reviewer Review Type Date Requested Status
Tim Bentley 2016-01-09 Approve on 2016-01-09
Review via email: mp+282093@code.launchpad.net

Description of the change

Disable OpenGL in the maindisplay on windows for now, fixes bug.
Fix for easyslide importer and added test.
Made song-importer-list sorted, again.
Small cleanup of videopsalm
Made sundayplus importer work with python3. Added tests.
Fix some tests on windows.
Pep8 fixes

To post a comment you must log in.
lp:~tomasgroth/openlp/importer-fixes updated on 2016-01-09
2598. By Tomas Groth on 2016-01-09

forgot to remove debug print

Tim Bentley (trb143) wrote :

Looks fine to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/common/settings.py'
2--- openlp/core/common/settings.py 2015-12-31 22:46:06 +0000
3+++ openlp/core/common/settings.py 2016-01-09 13:54:16 +0000
4@@ -252,7 +252,8 @@
5 'shortcuts/blankScreen': [QtGui.QKeySequence(QtCore.Qt.Key_Period)],
6 'shortcuts/collapse': [QtGui.QKeySequence(QtCore.Qt.Key_Minus)],
7 'shortcuts/desktopScreen': [QtGui.QKeySequence(QtCore.Qt.Key_D)],
8- 'shortcuts/delete': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
9+ 'shortcuts/delete': [QtGui.QKeySequence(QtGui.QKeySequence.Delete),
10+ QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
11 'shortcuts/down': [QtGui.QKeySequence(QtCore.Qt.Key_Down)],
12 'shortcuts/editSong': [],
13 'shortcuts/escapeItem': [QtGui.QKeySequence(QtCore.Qt.Key_Escape)],
14@@ -329,7 +330,8 @@
15 'shortcuts/moveBottom': [QtGui.QKeySequence(QtCore.Qt.Key_End)],
16 'shortcuts/moveDown': [QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
17 'shortcuts/nextTrackItem': [],
18- 'shortcuts/nextItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Down), QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
19+ 'shortcuts/nextItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Down),
20+ QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
21 'shortcuts/nextItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Down),
22 QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
23 'shortcuts/nextService': [QtGui.QKeySequence(QtCore.Qt.Key_Right)],
24@@ -339,7 +341,8 @@
25 QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F1)],
26 'shortcuts/openService': [],
27 'shortcuts/saveService': [],
28- 'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up), QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
29+ 'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up),
30+ QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
31 'shortcuts/playbackPause': [],
32 'shortcuts/playbackPlay': [],
33 'shortcuts/playbackStop': [],
34
35=== modified file 'openlp/core/ui/maindisplay.py'
36--- openlp/core/ui/maindisplay.py 2015-12-31 22:46:06 +0000
37+++ openlp/core/ui/maindisplay.py 2016-01-09 13:54:16 +0000
38@@ -34,7 +34,7 @@
39
40 from PyQt5 import QtCore, QtWidgets, QtWebKit, QtWebKitWidgets, QtOpenGL, QtGui, QtMultimedia
41
42-from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, Settings, translate, is_macosx
43+from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, Settings, translate, is_macosx, is_win
44 from openlp.core.lib import ServiceItem, ImageSource, ScreenList, build_html, expand_tags, image_to_byte
45 from openlp.core.lib.theme import BackgroundType
46 from openlp.core.ui import HideMode, AlertLocation
47@@ -90,7 +90,7 @@
48 # OpenGL. Only white blank screen is shown on the 2nd monitor all the
49 # time. We need to investigate more how to use OpenGL properly on Mac OS
50 # X.
51- if not is_macosx():
52+ if not is_macosx() and not is_win():
53 self.setViewport(QtOpenGL.QGLWidget())
54
55 def setup(self):
56@@ -121,7 +121,8 @@
57
58 :param event: The event to be handled
59 """
60- self.web_view.setGeometry(0, 0, self.width(), self.height())
61+ if hasattr(self, 'web_view'):
62+ self.web_view.setGeometry(0, 0, self.width(), self.height())
63
64 def is_web_loaded(self, field=None):
65 """
66
67=== modified file 'openlp/core/ui/themeform.py'
68--- openlp/core/ui/themeform.py 2015-12-31 22:46:06 +0000
69+++ openlp/core/ui/themeform.py 2016-01-09 13:54:16 +0000
70@@ -159,7 +159,7 @@
71 if not event:
72 event = QtGui.QResizeEvent(self.size(), self.size())
73 QtWidgets.QWizard.resizeEvent(self, event)
74- if self.currentPage() == self.preview_page:
75+ if hasattr(self, 'preview_page') and self.currentPage() == self.preview_page:
76 frame_width = self.preview_box_label.lineWidth()
77 pixmap_width = self.preview_area.width() - 2 * frame_width
78 pixmap_height = self.preview_area.height() - 2 * frame_width
79
80=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
81--- openlp/plugins/custom/lib/mediaitem.py 2016-01-08 17:28:47 +0000
82+++ openlp/plugins/custom/lib/mediaitem.py 2016-01-09 13:54:16 +0000
83@@ -190,7 +190,7 @@
84 if QtWidgets.QMessageBox.question(
85 self, UiStrings().ConfirmDelete,
86 translate('CustomPlugin.MediaItem',
87- 'Are you sure you want to delete the "%d" selected custom slide(s)?') %len(items),
88+ 'Are you sure you want to delete the "%d" selected custom slide(s)?') % len(items),
89 QtWidgets.QMessageBox.StandardButtons(
90 QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No),
91 QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No:
92
93=== modified file 'openlp/plugins/songs/lib/importer.py'
94--- openlp/plugins/songs/lib/importer.py 2015-12-31 22:46:06 +0000
95+++ openlp/plugins/songs/lib/importer.py 2016-01-09 13:54:16 +0000
96@@ -153,23 +153,23 @@
97 EasyWorshipDB = 6
98 EasyWorshipService = 7
99 FoilPresenter = 8
100- MediaShout = 9
101- OpenSong = 10
102- PowerPraise = 11
103- PowerSong = 12
104- PresentationManager = 13
105- ProPresenter = 14
106- SongBeamer = 15
107- SongPro = 16
108- SongShowPlus = 17
109- SongsOfFellowship = 18
110- SundayPlus = 19
111- WordsOfWorship = 20
112- WorshipAssistant = 21
113- WorshipCenterPro = 22
114- ZionWorx = 23
115- Lyrix = 24
116- VideoPsalm = 25
117+ Lyrix = 9
118+ MediaShout = 10
119+ OpenSong = 11
120+ PowerPraise = 12
121+ PowerSong = 13
122+ PresentationManager = 14
123+ ProPresenter = 15
124+ SongBeamer = 16
125+ SongPro = 17
126+ SongShowPlus = 18
127+ SongsOfFellowship = 19
128+ SundayPlus = 20
129+ VideoPsalm = 21
130+ WordsOfWorship = 22
131+ WorshipAssistant = 23
132+ WorshipCenterPro = 24
133+ ZionWorx = 25
134
135 # Set optional attribute defaults
136 __defaults__ = {
137
138=== modified file 'openlp/plugins/songs/lib/importers/easyslides.py'
139--- openlp/plugins/songs/lib/importers/easyslides.py 2015-12-31 22:46:06 +0000
140+++ openlp/plugins/songs/lib/importers/easyslides.py 2016-01-09 13:54:16 +0000
141@@ -65,7 +65,8 @@
142 self._add_unicode_attribute('song_number', song.SongNumber)
143 if self.song_number == '0':
144 self.song_number = ''
145- self._add_authors(song)
146+ if hasattr(song, 'Writer'):
147+ self._add_authors(song.Writer)
148 if hasattr(song, 'Copyright'):
149 self._add_copyright(song.Copyright)
150 if hasattr(song, 'LicenceAdmin1'):
151@@ -102,15 +103,12 @@
152 if mandatory:
153 self._success = False
154
155- def _add_authors(self, song):
156+ def _add_authors(self, writer):
157 try:
158- authors = str(song.Writer).split(',')
159- self.authors = [author.strip() for author in authors if author.strip()]
160- except UnicodeDecodeError:
161+ self.parse_author(str(writer))
162+ except UnicodeDecodeError as e:
163 log.exception('Unicode decode error while decoding Writer')
164 self._success = False
165- except AttributeError:
166- pass
167
168 def _add_copyright(self, element):
169 """
170@@ -234,11 +232,10 @@
171 for [reg, vt, vn, inst] in our_verse_order:
172 if self._list_has(verses, [reg, vt, vn, inst]):
173 # this is false, but needs user input
174- lang = None
175 versetag = '%s%s' % (vt, vn)
176 versetags.append(versetag)
177 lines = '\n'.join(verses[reg][vt][vn][inst])
178- self.verses.append([versetag, lines, lang])
179+ self.add_verse(lines, versetag)
180 SeqTypes = {
181 'p': 'P1',
182 'q': 'P2',
183
184=== modified file 'openlp/plugins/songs/lib/importers/sundayplus.py'
185--- openlp/plugins/songs/lib/importers/sundayplus.py 2015-12-31 22:46:06 +0000
186+++ openlp/plugins/songs/lib/importers/sundayplus.py 2016-01-09 13:54:16 +0000
187@@ -22,6 +22,8 @@
188
189 import os
190 import re
191+import logging
192+
193
194 from openlp.plugins.songs.lib import VerseType, retrieve_windows_encoding
195 from openlp.plugins.songs.lib import strip_rtf
196@@ -53,8 +55,8 @@
197 """
198 Initialise the class.
199 """
200- SongImport.__init__(self, manager, **kwargs)
201- self.encoding = 'us-ascii'
202+ super(SundayPlusImport, self).__init__(manager, **kwargs)
203+ self.encoding = 'cp1252'
204
205 def do_import(self):
206 self.import_wizard.progress_bar.setMaximum(len(self.import_source))
207@@ -73,7 +75,7 @@
208 if not self.parse(file.read()):
209 self.log_error(file.name)
210 return
211- if not self.title:
212+ if self.title == '':
213 self.title = self.title_from_filename(file.name)
214 if not self.finish():
215 self.log_error(file.name)
216@@ -86,7 +88,7 @@
217 :param cell: ?
218 :return:
219 """
220- if len(data) == 0 or data[0:1] != '[' or data[-1] != ']':
221+ if not cell and (len(data) == 0 or data[0:1] != b'[' or data.strip()[-1:] != b']'):
222 self.log_error('File is malformed')
223 return False
224 i = 1
225@@ -94,31 +96,31 @@
226 while i < len(data):
227 # Data is held as #name: value pairs inside groups marked as [].
228 # Now we are looking for the name.
229- if data[i:i + 1] == '#':
230- name_end = data.find(':', i + 1)
231- name = data[i + 1:name_end].upper()
232+ if data[i:i + 1] == b'#':
233+ name_end = data.find(b':', i + 1)
234+ name = data[i + 1:name_end].decode(self.encoding).upper()
235 i = name_end + 1
236- while data[i:i + 1] == ' ':
237+ while data[i:i + 1] == b' ':
238 i += 1
239- if data[i:i + 1] == '"':
240- end = data.find('"', i + 1)
241+ if data[i:i + 1] == b'"':
242+ end = data.find(b'"', i + 1)
243 value = data[i + 1:end]
244- elif data[i:i + 1] == '[':
245+ elif data[i:i + 1] == b'[':
246 j = i
247 inside_quotes = False
248 while j < len(data):
249 char = data[j:j + 1]
250- if char == '"':
251+ if char == b'"':
252 inside_quotes = not inside_quotes
253- elif not inside_quotes and char == ']':
254+ elif not inside_quotes and char == b']':
255 end = j + 1
256 break
257 j += 1
258 value = data[i:end]
259 else:
260- end = data.find(',', i + 1)
261- if data.find('(', i, end) != -1:
262- end = data.find(')', i) + 1
263+ end = data.find(b',', i + 1)
264+ if data.find(b'(', i, end) != -1:
265+ end = data.find(b')', i) + 1
266 value = data[i:end]
267 # If we are in the main group.
268 if not cell:
269@@ -129,27 +131,29 @@
270 if len(author):
271 self.add_author(author)
272 elif name == 'COPYRIGHT':
273- self.copyright = self.decode(self.unescape(value))
274+ self.add_copyright(self.decode(self.unescape(value)))
275 elif name[0:4] == 'CELL':
276 self.parse(value, cell=name[4:])
277 # We are in a verse group.
278 else:
279 if name == 'MARKER_NAME':
280- value = value.strip()
281+ value = self.decode(value).strip()
282 if len(value):
283 verse_type = VerseType.tags[VerseType.from_loose_input(value[0])]
284 if len(value) >= 2 and value[-1] in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:
285 verse_type = "%s%s" % (verse_type, value[-1])
286 elif name == 'HOTKEY':
287+ value = self.decode(value).strip()
288 # HOTKEY always appears after MARKER_NAME, so it
289 # effectively overrides MARKER_NAME, if present.
290 if len(value) and value in list(HOTKEY_TO_VERSE_TYPE.keys()):
291 verse_type = HOTKEY_TO_VERSE_TYPE[value]
292 if name == 'RTF':
293 value = self.unescape(value)
294+ value = self.decode(value)
295 result = strip_rtf(value, self.encoding)
296 if result is None:
297- return
298+ return False
299 verse, self.encoding = result
300 lines = verse.strip().split('\n')
301 # If any line inside any verse contains CCLI or
302@@ -164,7 +168,7 @@
303 self.ccli_number = int(m.group(0))
304 continue
305 elif line.lower() == 'public domain':
306- self.copyright = 'Public Domain'
307+ self.add_copyright('Public Domain')
308 continue
309 processed_lines.append(line)
310 self.add_verse('\n'.join(processed_lines).strip(), verse_type)
311@@ -192,11 +196,11 @@
312 def decode(self, blob):
313 while True:
314 try:
315- return str(blob, self.encoding)
316- except:
317+ return blob.decode(self.encoding)
318+ except Exception as e:
319 self.encoding = retrieve_windows_encoding()
320
321 def unescape(self, text):
322- text = text.replace('^^', '"')
323- text = text.replace('^', '\'')
324+ text = text.replace(b'^^', b'"')
325+ text = text.replace(b'^', b'\'')
326 return text.strip()
327
328=== modified file 'openlp/plugins/songs/lib/importers/videopsalm.py'
329--- openlp/plugins/songs/lib/importers/videopsalm.py 2015-12-31 22:46:06 +0000
330+++ openlp/plugins/songs/lib/importers/videopsalm.py 2016-01-09 13:54:16 +0000
331@@ -28,7 +28,6 @@
332 import os
333
334 from openlp.core.common import translate
335-from openlp.plugins.songs.lib import VerseType
336 from openlp.plugins.songs.lib.importers.songimport import SongImport
337 from openlp.plugins.songs.lib.db import AuthorType
338
339
340=== modified file 'tests/functional/openlp_core_lib/test_mediamanageritem.py'
341--- tests/functional/openlp_core_lib/test_mediamanageritem.py 2016-01-07 12:36:11 +0000
342+++ tests/functional/openlp_core_lib/test_mediamanageritem.py 2016-01-09 13:54:16 +0000
343@@ -75,7 +75,6 @@
344 self.assertTrue(mmi.has_delete_icon, 'By default a delete icon should be present')
345 self.assertFalse(mmi.add_to_service_item, 'There should be no add_to_service icon by default')
346
347-
348 @patch(u'openlp.core.lib.mediamanageritem.Settings')
349 @patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
350 def on_double_clicked_go_live_test(self, mocked_on_live_click, MockedSettings):
351
352=== modified file 'tests/functional/openlp_core_lib/test_projectordb.py'
353--- tests/functional/openlp_core_lib/test_projectordb.py 2016-01-07 21:57:01 +0000
354+++ tests/functional/openlp_core_lib/test_projectordb.py 2016-01-09 13:54:16 +0000
355@@ -185,4 +185,3 @@
356 # THEN: Projector should have the same source entry
357 item = self.projector.get_projector_by_id(item_id)
358 self.assertTrue(compare_source(item.source_list[0], source))
359-
360
361=== added file 'tests/functional/openlp_plugins/songs/test_easyslidesimport.py'
362--- tests/functional/openlp_plugins/songs/test_easyslidesimport.py 1970-01-01 00:00:00 +0000
363+++ tests/functional/openlp_plugins/songs/test_easyslidesimport.py 2016-01-09 13:54:16 +0000
364@@ -0,0 +1,45 @@
365+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
366+
367+###############################################################################
368+# OpenLP - Open Source Lyrics Projection #
369+# --------------------------------------------------------------------------- #
370+# Copyright (c) 2008-2016 OpenLP Developers #
371+# --------------------------------------------------------------------------- #
372+# This program is free software; you can redistribute it and/or modify it #
373+# under the terms of the GNU General Public License as published by the Free #
374+# Software Foundation; version 2 of the License. #
375+# #
376+# This program is distributed in the hope that it will be useful, but WITHOUT #
377+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
378+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
379+# more details. #
380+# #
381+# You should have received a copy of the GNU General Public License along #
382+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
383+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
384+###############################################################################
385+"""
386+This module contains tests for the EasySlides song importer.
387+"""
388+
389+import os
390+
391+from tests.helpers.songfileimport import SongImportTestHelper
392+
393+TEST_PATH = os.path.abspath(
394+ os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'easyslidessongs'))
395+
396+
397+class TestEasySlidesFileImport(SongImportTestHelper):
398+
399+ def __init__(self, *args, **kwargs):
400+ self.importer_class_name = 'EasySlidesImport'
401+ self.importer_module_name = 'easyslides'
402+ super(TestEasySlidesFileImport, self).__init__(*args, **kwargs)
403+
404+ def test_song_import(self):
405+ """
406+ Test that loading an EasySlides file works correctly on various files
407+ """
408+ self.file_import(os.path.join(TEST_PATH, 'amazing-grace.xml'),
409+ self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
410
411=== modified file 'tests/functional/openlp_plugins/songs/test_songformat.py'
412--- tests/functional/openlp_plugins/songs/test_songformat.py 2016-01-05 21:35:35 +0000
413+++ tests/functional/openlp_plugins/songs/test_songformat.py 2016-01-09 13:54:16 +0000
414@@ -81,4 +81,3 @@
415 # THEN: Return all attributes that were specified
416 self.assertEquals(len(SongFormat.get(song_format, 'canDisable', 'availability')), 2,
417 "Did not return the correct number of attributes when retrieving multiple attributes at once")
418-
419
420=== added file 'tests/functional/openlp_plugins/songs/test_sundayplusimport.py'
421--- tests/functional/openlp_plugins/songs/test_sundayplusimport.py 1970-01-01 00:00:00 +0000
422+++ tests/functional/openlp_plugins/songs/test_sundayplusimport.py 2016-01-09 13:54:16 +0000
423@@ -0,0 +1,51 @@
424+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
425+
426+###############################################################################
427+# OpenLP - Open Source Lyrics Projection #
428+# --------------------------------------------------------------------------- #
429+# Copyright (c) 2008-2016 OpenLP Developers #
430+# --------------------------------------------------------------------------- #
431+# This program is free software; you can redistribute it and/or modify it #
432+# under the terms of the GNU General Public License as published by the Free #
433+# Software Foundation; version 2 of the License. #
434+# #
435+# This program is distributed in the hope that it will be useful, but WITHOUT #
436+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
437+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
438+# more details. #
439+# #
440+# You should have received a copy of the GNU General Public License along #
441+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
442+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
443+###############################################################################
444+"""
445+This module contains tests for the VideoPsalm song importer.
446+"""
447+
448+import os
449+
450+from tests.helpers.songfileimport import SongImportTestHelper
451+from tests.functional import patch
452+
453+TEST_PATH = os.path.abspath(
454+ os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'sundayplussongs'))
455+
456+
457+class TestSundayPlusFileImport(SongImportTestHelper):
458+
459+ def __init__(self, *args, **kwargs):
460+ self.importer_class_name = 'SundayPlusImport'
461+ self.importer_module_name = 'sundayplus'
462+ super(TestSundayPlusFileImport, self).__init__(*args, **kwargs)
463+
464+ def test_song_import(self):
465+ """
466+ Test that loading an SundayPlus file works correctly on various files
467+ """
468+ with patch('openlp.plugins.songs.lib.importers.sundayplus.retrieve_windows_encoding') as \
469+ mocked_retrieve_windows_encoding:
470+ mocked_retrieve_windows_encoding.return_value = 'cp1252'
471+ self.file_import([os.path.join(TEST_PATH, 'Abba Fader.ptf')],
472+ self.load_external_result_data(os.path.join(TEST_PATH, 'abba-fader.json')))
473+ self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.ptf')],
474+ self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
475
476=== modified file 'tests/functional/openlp_plugins/songs/test_videopsalm.py'
477--- tests/functional/openlp_plugins/songs/test_videopsalm.py 2015-12-31 22:46:06 +0000
478+++ tests/functional/openlp_plugins/songs/test_videopsalm.py 2016-01-09 13:54:16 +0000
479@@ -26,7 +26,6 @@
480 from unittest import TestCase
481
482 from tests.helpers.songfileimport import SongImportTestHelper
483-from openlp.plugins.songs.lib.importers.opensong import OpenSongImport
484 from openlp.core.common import Registry
485 from tests.functional import patch, MagicMock
486
487
488=== modified file 'tests/helpers/testmixin.py'
489--- tests/helpers/testmixin.py 2015-12-31 22:46:06 +0000
490+++ tests/helpers/testmixin.py 2016-01-09 13:54:16 +0000
491@@ -48,13 +48,17 @@
492 """
493 Build the settings Object and initialise it
494 """
495- Settings.setDefaultFormat(Settings.IniFormat)
496 self.fd, self.ini_file = mkstemp('.ini')
497- Settings().set_filename(self.ini_file)
498+ Settings.set_filename(self.ini_file)
499+ Settings().setDefaultFormat(Settings.IniFormat)
500+ # Needed on windows to make sure a Settings object is available during the tests
501+ self.setting = Settings()
502+ Settings().setValue('themes/global theme', 'my_theme')
503
504 def destroy_settings(self):
505 """
506 Destroy the Settings Object
507 """
508+ del self.setting
509 os.close(self.fd)
510 os.unlink(Settings().fileName())
511
512=== modified file 'tests/interfaces/openlp_core_ui/test_projectoreditform.py'
513--- tests/interfaces/openlp_core_ui/test_projectoreditform.py 2016-01-07 21:36:43 +0000
514+++ tests/interfaces/openlp_core_ui/test_projectoreditform.py 2016-01-09 13:54:16 +0000
515@@ -103,5 +103,3 @@
516 'Projector edit form should be marked as existing entry')
517 self.assertTrue((item.ip is TEST1_DATA['ip'] and item.name is TEST1_DATA['name']),
518 'Projector edit form should have TEST1_DATA() instance to edit')
519-
520-
521
522=== added directory 'tests/resources/easyslidessongs'
523=== added file 'tests/resources/easyslidessongs/Amazing Grace.json'
524--- tests/resources/easyslidessongs/Amazing Grace.json 1970-01-01 00:00:00 +0000
525+++ tests/resources/easyslidessongs/Amazing Grace.json 2016-01-09 13:54:16 +0000
526@@ -0,0 +1,32 @@
527+{
528+ "title": "Amazing Grace",
529+ "authors": [
530+ "John Newton (1725-1807)"
531+ ],
532+ "verses": [
533+ [
534+ "Amazing grace! How sweet the sound\nThat saved a wretch like me;\nI once was lost, but now am found,\nWas blind, but now I see.",
535+ "V1"
536+ ],
537+ [
538+ "'Twas grace that taught my heart to fear,\nAnd grace my fears relieved;\nHow precious did that grace appear,\nThe hour I first believed!",
539+ "V2"
540+ ],
541+ [
542+ "Through many dangers, toils and snares\nI have already come;\n'Tis grace that brought me safe thus far,\nAnd grace will lead me home.",
543+ "V3"
544+ ],
545+ [
546+ "The Lord has promised good to me,\nHis word my hope secures;\nHe will my shield and portion be\nAs long as life endures.",
547+ "V4"
548+ ],
549+ [
550+ "Yes, when this heart and flesh shall fail,\nAnd mortal life shall cease,\nI shall possess within the veil\nA life of joy and peace.",
551+ "V5"
552+ ],
553+ [
554+ "When we've been there a thousand years,\nBright shining as the sun,\nWe've no less days to sing God's praise\nThan when we first begun.",
555+ "V6"
556+ ]
557+ ]
558+}
559
560=== added file 'tests/resources/easyslidessongs/amazing-grace.xml'
561--- tests/resources/easyslidessongs/amazing-grace.xml 1970-01-01 00:00:00 +0000
562+++ tests/resources/easyslidessongs/amazing-grace.xml 2016-01-09 13:54:16 +0000
563@@ -0,0 +1,53 @@
564+<?xml version="1.0" encoding="utf-8"?>
565+<EasiSlides>
566+ <Item>
567+ <Title1>Amazing Grace</Title1>
568+ <Title2 />
569+ <Folder>English</Folder>
570+ <SongNumber>0</SongNumber>
571+ <Contents>[1]
572+Amazing grace! How sweet the sound
573+That saved a wretch like me;
574+I once was lost, but now am found,
575+Was blind, but now I see.
576+[2]
577+'Twas grace that taught my heart to fear,
578+And grace my fears relieved;
579+How precious did that grace appear,
580+The hour I first believed!
581+[3]
582+Through many dangers, toils and snares
583+I have already come;
584+'Tis grace that brought me safe thus far,
585+And grace will lead me home.
586+[4]
587+The Lord has promised good to me,
588+His word my hope secures;
589+He will my shield and portion be
590+As long as life endures.
591+[5]
592+Yes, when this heart and flesh shall fail,
593+And mortal life shall cease,
594+I shall possess within the veil
595+A life of joy and peace.
596+[6]
597+When we've been there a thousand years,
598+Bright shining as the sun,
599+We've no less days to sing God's praise
600+Than when we first begun.</Contents>
601+ <Notations />
602+ <Sequence />
603+ <Writer>John Newton (1725-1807)</Writer>
604+ <Copyright />
605+ <Category />
606+ <Timing />
607+ <MusicKey />
608+ <Capo>-1</Capo>
609+ <LicenceAdmin1>Public Domain</LicenceAdmin1>
610+ <LicenceAdmin2 />
611+ <BookReference>SF19, MP31, TS18</BookReference>
612+ <UserReference />
613+ <FormatData />
614+ <Settings />
615+ </Item>
616+</EasiSlides>
617
618=== added directory 'tests/resources/sundayplussongs'
619=== added file 'tests/resources/sundayplussongs/Abba Fader.ptf'
620--- tests/resources/sundayplussongs/Abba Fader.ptf 1970-01-01 00:00:00 +0000
621+++ tests/resources/sundayplussongs/Abba Fader.ptf 2016-01-09 13:54:16 +0000
622@@ -0,0 +1,8 @@
623+[#PTFVersion: 2, #GLOBAL_RECT: rect(47,2,1026,770), #opacity: 100, #SHADOW_ON: 0, #SHADOW_COLOR: rgb( 0, 0, 0), #SHADOW_OPACITY: 100, #SHADOW_POSITION: "RB", #SHADOW_OFFSET: [0, 0], #FILE_TYPE: "Song", #title: "Abba Fader", #Author: "Okänd", #Copyright: "ccc", #CELL1: [#MARKER_NAME: "Abba Fader", #Hotkey: "1", #rtf: "{\rtf1\ansi\ansicpg1252\deff0\deflang1053{\fonttbl{\f0\froman\fprq2\fcharset0 Verdana;}{\f1\froman\fcharset0 Verdana;}}
624+{\colortbl ;\red255\green255\blue0;\red224\green223\blue227;}
625+\viewkind4\uc1\pard\cf1\b\f0\fs86 Abba Fader\par
626+\par
627+Vi \^e4r h\^e4r f\^f6r att prisa Dig\line Vi \^e4r h\^e4r med f\^f6rv\^e4ntan\line Vi \^e4r h\^e4r som ett enat folk\line Vi kommer fram till Dig\line Med v\^e5r lovs\^e5ng\line\fs59\line\fs86 Vi ropar Abba Fader\line Du som har all makt\line Vi ropar Abba Fader\line Till Dig st\^e5r allt v\^e5rt hopp\line Vi ropar Abba Fader\line V\^e5r fr\^e4lsare, befriare \^e4r Du\b0\line\pard\tx720\f1\par
628+\cf2\par
629+}
630+", #Align: #Left]]
631\ No newline at end of file
632
633=== added file 'tests/resources/sundayplussongs/Amazing Grace.json'
634--- tests/resources/sundayplussongs/Amazing Grace.json 1970-01-01 00:00:00 +0000
635+++ tests/resources/sundayplussongs/Amazing Grace.json 2016-01-09 13:54:16 +0000
636@@ -0,0 +1,26 @@
637+{
638+ "title": "Amazing Grace",
639+ "authors": [
640+ "John Newton"
641+ ],
642+ "copyright": "Public Domain",
643+ "cclinumber": "1234",
644+ "verses": [
645+ [
646+ "Amazing grace how sweet the sound\nThat saved a wretch like me;\nI once was lost, but now am found,\nWas blind, but now I see.",
647+ "v"
648+ ],
649+ [
650+ "’Twas grace that taught my heart to fear,\nAnd grace my fears relieved;\nHow precious did that grace appear,\nThe hour I first believed!",
651+ "v"
652+ ],
653+ [
654+ "Through many dangers, toils and snares\nI have already come;\n’Tis grace hath brought me safe thus far,\nAnd grace will lead me home.",
655+ "v"
656+ ],
657+ [
658+ "When we’ve been there ten thousand years,\nBright shining as the sun,\nWe’ve no less days to sing God’s praise\nThan when we first begun.",
659+ "v"
660+ ]
661+ ]
662+}
663
664=== added file 'tests/resources/sundayplussongs/Amazing Grace.ptf'
665--- tests/resources/sundayplussongs/Amazing Grace.ptf 1970-01-01 00:00:00 +0000
666+++ tests/resources/sundayplussongs/Amazing Grace.ptf 2016-01-09 13:54:16 +0000
667@@ -0,0 +1,43 @@
668+[#GLOBAL_RECT: rect(100, 150, 900, 1024), #Opacity: 100, #SHADOW_ON: 1, #SHADOW_COLOR: rgb( 0, 0, 0 ), #SHADOW_OPACITY: 100, #SHADOW_POSITION: "RB", #SHADOW_OFFSET: [4, 4], #FILE_TYPE: "Song", #title: "", #Author: "John Newton", #Copyright: "Public Domain", #CCLI: "1234", #Cell1: [#rtf: "{\rtf1\ansi\deff0 {\fonttbl{\f0\fswiss Arial;}{\f1\fmodern Monotype Corsiva;}{\f2\fswiss MS Serif;}{\f3\fnil Verdana;}}{\colortbl
669+\red0\green0\blue0;\red0\green0\blue224;\red224\green0\blue0;\red224\green0\blue224;\red102\green102\blue153;\red51\green153\blue102;
670+\red0\green255\blue0;\red255\green255\blue0;\red248\green248\blue248;}{\stylesheet{\s0\fs24\ql\li0\ri0\fi0\sb0\sa0\sl0 Normal;}{\s2
671+\fs24\ql\li0\ri0\fi0\sb0\sa0\sl0 Normal Text;}{\s3\fs24\ql\li0\ri0\fi0\sb0\sa0\sl0 Plain Text;}{\s4\fs130\cf4\ql\li0\ri0\fi0\sb0\sa0
672+\sl0 heading 1;}{\s5\fs192\cf5\ql\li0\ri0\fi0\sb0\sa0\sl0 heading 2;}{\s6\fs96\cf4\ql\li0\ri0\fi0\sb0\sa0\sl0 Body Text;}{\s7\b\fs96
673+\cf6\ql\li0\ri0\fi0\sb0\sa0\sl0 Author;}{\s8\b\fs40\ql\li0\ri0\fi0\sb0\sa0\sl0 CCLI;}{\s9\b\fs40\ql\li0\ri0\fi0\sb0\sa0\sl0 Copyright;}
674+{\s10\fs120\cf7\ql\li0\ri0\fi0\sb0\sa0\sl0 Lyrics;}{\s11\b\f1\fs144\ql\li0\ri0\fi0\sb0\sa0\sl0 Title;}{\s12\f2\fs16 02 VERSES;}{\s13
675+\f2\fs16 03 CHORUS (itals);}{\s14\f2\fs12 01a ATTRIBUTION (1 fig);}{\s15\f2\fs12 01b ATTRIBUTION (2 fig);}{\s16\f2\fs12 01c ATTRIBUTION (3 fig);}
676+{\s17\f2\fs12 01d ATTRIBUTION (4 fig);}}\margl1800 \margr1800 \margt1440 \margb1440 \pard \f0\fs24{\pard \s12\b\f3\fs96\cf8\ql\li0
677+\ri0\fi0\sb0\sa0\sl0 Amazing grace how sweet the sound\par
678+That saved a wretch like me;\par
679+I once was lost, but now am found,\par
680+Was blind, but now I see.\par
681+\par
682+}}", #Align: #left, #MARKER_NAME: "AMAZING GRACE", #Hotkey: "1"], #Cell2: [#rtf: "{\rtf1\ansi\deff0 {\fonttbl{\f0\fswiss Arial;}{\f1\fmodern Monotype Corsiva;}{\f2\fswiss MS Serif;}{\f3\fnil Verdana;}}{\colortbl
683+\red0\green0\blue0;\red0\green0\blue224;\red224\green0\blue0;\red224\green0\blue224;\red102\green102\blue153;\red51\green153\blue102;
684+\red0\green255\blue0;\red255\green255\blue0;\red248\green248\blue248;}{\stylesheet{\s0\fs24\ql\li0\ri0\fi0\sb0\sa0\sl0 Normal Text;}
685+{\s2\fs24\ql\li0\ri0\fi0\sb0\sa0\sl0 Normal;}{\s3\fs24\ql\li0\ri0\fi0\sb0\sa0\sl0 Plain Text;}{\s4\fs130\cf4\ql\li0\ri0\fi0\sb0\sa0
686+\sl0 heading 1;}{\s5\fs192\cf5\ql\li0\ri0\fi0\sb0\sa0\sl0 heading 2;}{\s6\fs96\cf4\ql\li0\ri0\fi0\sb0\sa0\sl0 Body Text;}{\s7\b\fs96
687+\cf6 Author;}{\s8\b\fs40 CCLI;}{\s9\b\fs40 Copyright;}{\s10\fs120\cf7 Lyrics;}{\s11\b\f1\fs144 Title;}{\s12\f2\fs16 02 VERSES;}}\margl1800
688+\margr1800 \margt1440 \margb1440 \pard \f0\fs24{\b\f3\fs96\cf8 \^92Twas grace that taught my heart to fear,\par
689+And grace my fears relieved;\par
690+How precious did that grace appear,\par
691+The hour I first believed!\par
692+\par
693+}}", #Align: #left, #MARKER_NAME: "AMAZING GRACE", #Hotkey: "2"], #Cell3: [#rtf: "{\rtf1\ansi\deff0 {\fonttbl{\f0\fswiss Arial;}{\f1\fmodern Monotype Corsiva;}{\f2\fswiss MS Serif;}{\f3\fnil Verdana;}}{\colortbl
694+\red0\green0\blue0;\red0\green0\blue224;\red224\green0\blue0;\red224\green0\blue224;\red102\green102\blue153;\red51\green153\blue102;
695+\red0\green255\blue0;\red255\green255\blue0;\red248\green248\blue248;}{\stylesheet{\s0\fs24\ql\li0\ri0\fi0\sb0\sa0\sl0 Normal Text;}
696+{\s2\fs24\ql\li0\ri0\fi0\sb0\sa0\sl0 Normal;}{\s3\fs24\ql\li0\ri0\fi0\sb0\sa0\sl0 Plain Text;}{\s4\fs130\cf4\ql\li0\ri0\fi0\sb0\sa0
697+\sl0 heading 1;}{\s5\fs192\cf5\ql\li0\ri0\fi0\sb0\sa0\sl0 heading 2;}{\s6\fs96\cf4\ql\li0\ri0\fi0\sb0\sa0\sl0 Body Text;}{\s7\b\fs96
698+\cf6 Author;}{\s8\b\fs40 CCLI;}{\s9\b\fs40 Copyright;}{\s10\fs120\cf7 Lyrics;}{\s11\b\f1\fs144 Title;}{\s12\f2\fs16 02 VERSES;}}\margl1800
699+\margr1800 \margt1440 \margb1440 \pard \f0\fs24{\b\f3\fs96\cf8 Through many dangers, toils and snares\par
700+I have already come;\par
701+\^92Tis grace hath brought me safe thus far,\par
702+And grace will lead me home.\par
703+\par
704+}}", #Align: #left, #MARKER_NAME: "AMAZING GRACE", #Hotkey: "3"], #CELL4: [#rtf: "{\rtf1\ansi\deff0 {\fonttbl{\f0\fswiss Arial;}{\f1\fnil Verdana;}}{\colortbl\red0\green0\blue0;\red0\green0\blue224;\red224\green0
705+\blue0;\red224\green0\blue224;\red248\green248\blue248;}{\stylesheet{\s0\fs24 Normal Text;}}\margl1800 \margr1800 \margt1440 \margb1440
706+\pard \f0\fs24{\b\f1\fs96\cf4 When we\^92ve been there ten thousand years,\par
707+Bright shining as the sun,\par
708+We\^92ve no less days to sing God\^92s praise\par
709+Than when we first begun.\par
710+}}", #Align: #left, #MARKER_NAME: "AMAZING GRACE", #Hotkey: "4"], #CELL5: [:]]
711
712=== added file 'tests/resources/sundayplussongs/abba-fader.json'
713--- tests/resources/sundayplussongs/abba-fader.json 1970-01-01 00:00:00 +0000
714+++ tests/resources/sundayplussongs/abba-fader.json 2016-01-09 13:54:16 +0000
715@@ -0,0 +1,13 @@
716+{
717+ "authors": [
718+ ["Okänd"]
719+ ],
720+ "title": "Abba Fader",
721+ "verse_order_list": [],
722+ "verses": [
723+ [
724+ "Abba Fader\n\nVi är här för att prisa Dig\nVi är här med förväntan\nVi är här som ett enat folk\nVi kommer fram till Dig\nMed vår lovsång\n\nVi ropar Abba Fader\nDu som har all makt\nVi ropar Abba Fader\nTill Dig står allt vårt hopp\nVi ropar Abba Fader\nVår frälsare, befriare är Du",
725+ "v1"
726+ ]
727+ ]
728+}