forked from openlp/openlp
Add test
This commit is contained in:
parent
63f08f0c4a
commit
0bf256070a
@ -55,11 +55,11 @@ class ProPresenterImport(SongImport):
|
||||
return
|
||||
self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % os.path.basename(file_path))
|
||||
root = objectify.parse(open(file_path, 'rb')).getroot()
|
||||
self.process_song(root)
|
||||
self.process_song(root, file_path)
|
||||
|
||||
def process_song(self, root):
|
||||
def process_song(self, root, filename):
|
||||
self.set_defaults()
|
||||
self.title = root.get('CCLISongTitle')
|
||||
self.title = os.path.basename(filename).rstrip('.pro4')
|
||||
self.copyright = root.get('CCLICopyrightInfo')
|
||||
self.comments = root.get('notes')
|
||||
self.ccli_number = root.get('CCLILicenseNumber')
|
||||
@ -77,8 +77,5 @@ class ProPresenterImport(SongImport):
|
||||
rtf = base64.standard_b64decode(RTFData)
|
||||
words, encoding = strip_rtf(rtf.decode())
|
||||
self.add_verse(words, "v%d" % count)
|
||||
# Some songs don't have a title - use the first line as title
|
||||
if not self.title:
|
||||
self.title = self.guess_title()
|
||||
if not self.finish():
|
||||
self.log_error(self.import_source)
|
||||
|
@ -316,15 +316,6 @@ class SongImport(QtCore.QObject):
|
||||
self.verse_order_list_generated.append(self.verse_order_list_generated[-1])
|
||||
self.verse_order_list_generated_useful = True
|
||||
|
||||
def guess_title(self):
|
||||
"""
|
||||
Guess the title from the first verse (to be used when the song has no title information)
|
||||
:return: The guessed title
|
||||
"""
|
||||
if not self.verses:
|
||||
return ''
|
||||
return self.verses[0][1].split('\n')[0].strip()
|
||||
|
||||
def check_complete(self):
|
||||
"""
|
||||
Check the mandatory fields are entered (i.e. title and a verse)
|
||||
|
@ -52,3 +52,5 @@ class TestProPresenterFileImport(SongImportTestHelper):
|
||||
"""
|
||||
self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.pro4')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
|
||||
self.file_import([os.path.join(TEST_PATH, 'Vaste Grond.pro4')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'Vaste Grond.json')))
|
||||
|
34
tests/resources/propresentersongs/Vaste Grond.json
Normal file
34
tests/resources/propresentersongs/Vaste Grond.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"title": "Vaste Grond",
|
||||
"verse_order_list": [],
|
||||
"verses": [
|
||||
[
|
||||
"God voor U is niets onmogelijk\nHoe ongelofelijk\nU heeft alles in de hand",
|
||||
"v1"
|
||||
],
|
||||
[
|
||||
"U bent God en trekt Uw eigen plan\nU bent voor niemand bang\nVoor niets en niemand bang",
|
||||
"v2"
|
||||
],
|
||||
[
|
||||
"U houd me vast en geeft me moed\nOm door te gaan als ik niet durf\nIk wil van U zijn",
|
||||
"v3"
|
||||
],
|
||||
[
|
||||
"U geeft me kracht, en bent de vaste grond\nwaarop ik stevig sta\nik wil van U zijn, voor altijd van U zijn\nO God.",
|
||||
"v4"
|
||||
],
|
||||
[
|
||||
"Grote God, U bent uitzonderlijk\nen ondoorgrondelijk\nU biedt Uw liefde aan",
|
||||
"v5"
|
||||
],
|
||||
[
|
||||
"Wie ben ik, dat U mij ziet staan\nen met mij om wilt gaan?\nIk kan U niet weerstaan",
|
||||
"v6"
|
||||
],
|
||||
[
|
||||
"Onweerstaanbaar,\nonweerstaanbare God",
|
||||
"v7"
|
||||
]
|
||||
]
|
||||
}
|
1
tests/resources/propresentersongs/Vaste Grond.pro4
Normal file
1
tests/resources/propresentersongs/Vaste Grond.pro4
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user