From ae8b2d051af5162b3b8ad017a5f7bf5060224529 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 19 Oct 2015 22:14:30 +0100 Subject: [PATCH 1/7] Fix about dialog from translators --- openlp/core/ui/aboutdialog.py | 247 +++++++++++++++++++--------------- 1 file changed, 140 insertions(+), 107 deletions(-) diff --git a/openlp/core/ui/aboutdialog.py b/openlp/core/ui/aboutdialog.py index 4043d6352..ab3f4b64f 100644 --- a/openlp/core/ui/aboutdialog.py +++ b/openlp/core/ui/aboutdialog.py @@ -154,114 +154,147 @@ class UiAboutDialog(object): 'zh_CN': [' "executor" '] } documentors = ['Wesley "wrst" Stout', 'John "jseagull1" Cegalis (lead)'] + project_lead = translate('OpenLP.AboutForm', 'Project Lead') + devs = translate('OpenLP.AboutForm', 'Developers') + cons = translate('OpenLP.AboutForm', 'Contributors') + packs = translate('OpenLP.AboutForm', 'Packagers') + tests = translate('OpenLP.AboutForm', 'Testers') + laters = translate('OpenLP.AboutForm', 'Translators') + af = translate('OpenLP.AboutForm', 'Afrikaans (af)') + cs = translate('OpenLP.AboutForm', 'Czech (cs)') + da = translate('OpenLP.AboutForm', 'Danish (da)') + de = translate('OpenLP.AboutForm', 'German (de)') + el = translate('OpenLP.AboutForm', 'Greek (el)') + gb = translate('OpenLP.AboutForm', 'English, United Kingdom (en_GB)') + enza = translate('OpenLP.AboutForm', 'English, South Africa (en_ZA)') + es = translate('OpenLP.AboutForm', 'Spanish (es)') + et = translate('OpenLP.AboutForm', 'Estonian (et)') + fi = translate('OpenLP.AboutForm', 'Finnish (fi)') + fr = translate('OpenLP.AboutForm', 'French (fr)') + hu = translate('OpenLP.AboutForm', 'Hungarian (hu)') + id = translate('OpenLP.AboutForm', 'Indonesian (id)') + ja = translate('OpenLP.AboutForm', 'Japanese (ja)') + nb = translate('OpenLP.AboutForm', 'Norwegian Bokm\xe5l (nb)') + nl = translate('OpenLP.AboutForm', 'Dutch (nl)') + pl = translate('OpenLP.AboutForm', 'Polish (pl)') + ptbr = translate('OpenLP.AboutForm', 'Portuguese, Brazil (pt_BR)') + ru = translate('OpenLP.AboutForm', 'Russian (ru)') + sv = translate('OpenLP.AboutForm', 'Swedish (sv)') + talk = translate('OpenLP.AboutForm', 'Tamil(Sri-Lanka) (ta_LK)') + zhcn = translate('OpenLP.AboutForm', 'Chinese(China) (zh_CN)') + documentation = translate('OpenLP.AboutForm', 'Documentation') + built_with = translate('OpenLP.AboutForm', 'Built With\n' + ' Python: http://www.python.org/\n' + ' Qt4: http://qt.io\n' + ' PyQt4: http://www.riverbankcomputing.co.uk/software/pyqt/intro\n' + ' Oxygen Icons: http://techbase.kde.org/Projects/Oxygen/\n' + ' MuPDF: http://www.mupdf.com/\n') + final_credit = translate('OpenLP.AboutForm', 'Final Credit\n' + ' "For God so loved the world that He gave\n' + ' His one and only Son, so that whoever\n' + ' believes in Him will not perish but inherit\n' + ' eternal life." -- John 3:16\n\n' + ' And last but not least, final credit goes to\n' + ' God our Father, for sending His Son to die\n' + ' on the cross, setting us free from sin. We\n' + ' bring this software to you for free because\n' + ' He has set us free.') self.credits_text_edit.setPlainText( - translate('OpenLP.AboutForm', - 'Project Lead\n' - ' %s\n' - '\n' - 'Developers\n' - ' %s\n' - '\n' - 'Contributors\n' - ' %s\n' - '\n' - 'Testers\n' - ' %s\n' - '\n' - 'Packagers\n' - ' %s\n' - '\n' - 'Translators\n' - ' Afrikaans (af)\n' - ' %s\n' - ' Czech (cs)\n' - ' %s\n' - ' Danish (da)\n' - ' %s\n' - ' German (de)\n' - ' %s\n' - ' Greek (el)\n' - ' %s\n' - ' English, United Kingdom (en_GB)\n' - ' %s\n' - ' English, South Africa (en_ZA)\n' - ' %s\n' - ' Spanish (es)\n' - ' %s\n' - ' Estonian (et)\n' - ' %s\n' - ' Finnish (fi)\n' - ' %s\n' - ' French (fr)\n' - ' %s\n' - ' Hungarian (hu)\n' - ' %s\n' - ' Indonesian (id)\n' - ' %s\n' - ' Japanese (ja)\n' - ' %s\n' - ' Norwegian Bokm\xe5l (nb)\n' - ' %s\n' - ' Dutch (nl)\n' - ' %s\n' - ' Polish (pl)\n' - ' %s\n' - ' Portuguese, Brazil (pt_BR)\n' - ' %s\n' - ' Russian (ru)\n' - ' %s\n' - ' Swedish (sv)\n' - ' %s\n' - ' Tamil(Sri-Lanka) (ta_LK)\n' - ' %s\n' - ' Chinese(China) (zh_CN)\n' - ' %s\n' - '\n' - 'Documentation\n' - ' %s\n' - '\n' - 'Built With\n' - ' Python: http://www.python.org/\n' - ' Qt4: http://qt.io\n' - ' PyQt4: http://www.riverbankcomputing.co.uk/software/pyqt/intro\n' - ' Oxygen Icons: http://techbase.kde.org/Projects/Oxygen/\n' - ' MuPDF: http://www.mupdf.com/\n' - '\n' - 'Final Credit\n' - ' "For God so loved the world that He gave\n' - ' His one and only Son, so that whoever\n' - ' believes in Him will not perish but inherit\n' - ' eternal life." -- John 3:16\n\n' - ' And last but not least, final credit goes to\n' - ' God our Father, for sending His Son to die\n' - ' on the cross, setting us free from sin. We\n' - ' bring this software to you for free because\n' - ' He has set us free.') % - (lead, '\n '.join(developers), - '\n '.join(contributors), '\n '.join(testers), - '\n '.join(packagers), '\n '.join(translators['af']), - '\n '.join(translators['cs']), - '\n '.join(translators['da']), - '\n '.join(translators['de']), - '\n '.join(translators['el']), - '\n '.join(translators['en_GB']), - '\n '.join(translators['en_ZA']), - '\n '.join(translators['es']), - '\n '.join(translators['et']), - '\n '.join(translators['fi']), - '\n '.join(translators['fr']), - '\n '.join(translators['hu']), - '\n '.join(translators['id']), - '\n '.join(translators['ja']), - '\n '.join(translators['nb']), - '\n '.join(translators['nl']), - '\n '.join(translators['pl']), - '\n '.join(translators['pt_BR']), - '\n '.join(translators['ru']), - '\n '.join(translators['sv']), - '\n '.join(translators['ta_LK']), - '\n '.join(translators['zh_CN']), - '\n '.join(documentors))) + '%s\n' + ' %s\n' + '\n' + '%s\n' + ' %s\n' + '\n' + '%s\n' + ' %s\n' + '\n' + '%s\n' + ' %s\n' + '\n' + '%s\n' + ' %s\n' + '\n' + '%s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + ' %s\n' + '\n' + '%s\n' + ' %s\n' + '\n' + '%s\n%s' % + (project_lead, lead, + devs, '\n '.join(developers), + cons, '\n '.join(contributors), + tests, '\n '.join(testers), + packs, '\n '.join(packagers), + laters, + af, '\n '.join(translators['af']), + cs, '\n '.join(translators['cs']), + da, '\n '.join(translators['da']), + de, '\n '.join(translators['de']), + el, '\n '.join(translators['el']), + gb, '\n '.join(translators['en_GB']), + enza, '\n '.join(translators['en_ZA']), + es, '\n '.join(translators['es']), + et, '\n '.join(translators['et']), + fi, '\n '.join(translators['fi']), + fr, '\n '.join(translators['fr']), + hu, '\n '.join(translators['hu']), + id, '\n '.join(translators['id']), + ja, '\n '.join(translators['ja']), + nb, '\n '.join(translators['nb']), + nl, '\n '.join(translators['nl']), + pl, '\n '.join(translators['pl']), + ptbr, '\n '.join(translators['pt_BR']), + ru, '\n '.join(translators['ru']), + sv, '\n '.join(translators['sv']), + talk, '\n '.join(translators['ta_LK']), + zhcn, '\n '.join(translators['zh_CN']), + documentation, '\n '.join(documentors), + built_with, final_credit)) self.about_notebook.setTabText(self.about_notebook.indexOf(self.credits_tab), translate('OpenLP.AboutForm', 'Credits')) copyright_note = translate('OpenLP.AboutForm', From 85f034abdd22ded912bf6ccc00e995f9288c1dc8 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 27 Oct 2015 12:28:13 +0000 Subject: [PATCH 2/7] Make zionwork imported work with python3 Fixes: https://launchpad.net/bugs/1510282 --- openlp/plugins/songs/lib/importers/zionworx.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/songs/lib/importers/zionworx.py b/openlp/plugins/songs/lib/importers/zionworx.py index 54133974d..c68446b31 100644 --- a/openlp/plugins/songs/lib/importers/zionworx.py +++ b/openlp/plugins/songs/lib/importers/zionworx.py @@ -75,7 +75,7 @@ class ZionWorxImport(SongImport): """ Receive a CSV file (from a ZionWorx database dump) to import. """ - with open(self.import_source, 'rb') as songs_file: + with open(self.import_source, 'rt') as songs_file: field_names = ['SongNum', 'Title1', 'Title2', 'Lyrics', 'Writer', 'Copyright', 'Keywords', 'DefaultStyle'] songs_reader = csv.DictReader(songs_file, field_names) @@ -123,8 +123,7 @@ class ZionWorxImport(SongImport): def _decode(self, str): """ - Decodes CSV input to unicode, stripping all control characters (except new lines). + Strips all control characters (except new lines). """ - # This encoding choice seems OK. ZionWorx has no option for setting the - # encoding for its songs, so we assume encoding is always the same. - return str(str, 'cp1252').translate(CONTROL_CHARS_MAP) + # ZionWorx has no option for setting the encoding for its songs, so we assume encoding is always the same. + return str.translate(CONTROL_CHARS_MAP) From d65fa351c33b7ddfb21477bf6fdcf670e47cfee7 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 27 Oct 2015 13:16:48 +0000 Subject: [PATCH 3/7] Added test for zionworx file import. --- .../plugins/songs/lib/importers/zionworx.py | 7 +-- .../songs/test_zionworximport.py | 18 ++++++++ tests/resources/zionworxsongs/zionworx.csv | 45 +++++++++++++++++++ tests/resources/zionworxsongs/zionworx.json | 30 +++++++++++++ 4 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 tests/resources/zionworxsongs/zionworx.csv create mode 100644 tests/resources/zionworxsongs/zionworx.json diff --git a/openlp/plugins/songs/lib/importers/zionworx.py b/openlp/plugins/songs/lib/importers/zionworx.py index c68446b31..a27d064b3 100644 --- a/openlp/plugins/songs/lib/importers/zionworx.py +++ b/openlp/plugins/songs/lib/importers/zionworx.py @@ -75,7 +75,8 @@ class ZionWorxImport(SongImport): """ Receive a CSV file (from a ZionWorx database dump) to import. """ - with open(self.import_source, 'rt') as songs_file: + # Encoding should always be ISO-8859-1 + with open(self.import_source, 'rt', encoding='ISO-8859-1') as songs_file: field_names = ['SongNum', 'Title1', 'Title2', 'Lyrics', 'Writer', 'Copyright', 'Keywords', 'DefaultStyle'] songs_reader = csv.DictReader(songs_file, field_names) @@ -112,10 +113,10 @@ class ZionWorxImport(SongImport): if line and not line.isspace(): verse += line + '\n' elif verse: - self.add_verse(verse) + self.add_verse(verse, 'v') verse = '' if verse: - self.add_verse(verse) + self.add_verse(verse, 'v') title = self.title if not self.finish(): self.log_error(translate('SongsPlugin.ZionWorxImport', 'Record %d') % index + diff --git a/tests/functional/openlp_plugins/songs/test_zionworximport.py b/tests/functional/openlp_plugins/songs/test_zionworximport.py index 775f3a78f..0e7ba16da 100644 --- a/tests/functional/openlp_plugins/songs/test_zionworximport.py +++ b/tests/functional/openlp_plugins/songs/test_zionworximport.py @@ -22,14 +22,18 @@ """ This module contains tests for the ZionWorx song importer. """ +import os from unittest import TestCase from tests.functional import MagicMock, patch +from tests.helpers.songfileimport import SongImportTestHelper from openlp.plugins.songs.lib.importers.zionworx import ZionWorxImport from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.core.common import Registry +TEST_PATH = os.path.abspath( + os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'zionworxsongs')) class TestZionWorxImport(TestCase): """ @@ -54,3 +58,17 @@ class TestZionWorxImport(TestCase): # THEN: The importer should be an instance of SongImport self.assertIsInstance(importer, SongImport) + +class TestZionWorxFileImport(SongImportTestHelper): + + def __init__(self, *args, **kwargs): + self.importer_class_name = 'ZionWorxImport' + self.importer_module_name = 'zionworx' + super(TestZionWorxFileImport, self).__init__(*args, **kwargs) + + def test_song_import(self): + """ + Test that loading an ZionWorx file works correctly on various files + """ + self.file_import(os.path.join(TEST_PATH, 'zionworx.csv'), + self.load_external_result_data(os.path.join(TEST_PATH, 'zionworx.json'))) diff --git a/tests/resources/zionworxsongs/zionworx.csv b/tests/resources/zionworxsongs/zionworx.csv new file mode 100644 index 000000000..9d6bd3f72 --- /dev/null +++ b/tests/resources/zionworxsongs/zionworx.csv @@ -0,0 +1,45 @@ +"1","Crown Him With Many Crowns",,"Crown him with many crowns, +The Lamb upon His throne; +Hark, how the heavenly anthem drowns +All music but its own! +Awake, my soul, and sing +Of Him who died for thee, +And hail Him as thy matchless King +Through all eternity. + +Crown Him the Lord of life, +Who triumphed o'er the grave +And rose victorious in the strife +For those He came to save: +His glories now we sing, +Who died and rose on high, +Who died eternal life to bring +And lives that death may die. + +Crown Him the Lord of love; +Behold His hands and side, +Those wounds yet visible above +In beauty glorified: +No angel in the sky +Can fully bear that sight, +But downward bends His burning eye +At mysteries so bright. + +Crown Him the Lord of peace, +Whose power a sceptre sways +From pole to pole, that wars may cease, +And all be prayer and praise: +His reign shall know no end, +And round His piercèd feet +Fair flowers of paradise extend +Their fragrance ever sweet. + +Crown Him the Lord of years, +The Potentate of time, +Creator of the rolling spheres, +Ineffably sublime! +All hail, Redeemer, hail! +For Thou hast died for me; +Thy praise shall never, never fail +Throughout eternity. +","Matthew Bridges","Public Domain",, diff --git a/tests/resources/zionworxsongs/zionworx.json b/tests/resources/zionworxsongs/zionworx.json new file mode 100644 index 000000000..865561ca6 --- /dev/null +++ b/tests/resources/zionworxsongs/zionworx.json @@ -0,0 +1,30 @@ +{ + "authors": [ + "Matthew Bridges" + ], + "copyright": "Public Domain", + "title": "Crown Him With Many Crowns", + "verse_order_list": [], + "verses": [ + [ + "Crown him with many crowns,\nThe Lamb upon His throne;\nHark, how the heavenly anthem drowns\nAll music but its own!\nAwake, my soul, and sing\nOf Him who died for thee,\nAnd hail Him as thy matchless King\nThrough all eternity.\n", + "v" + ], + [ + "Crown Him the Lord of life,\nWho triumphed o'er the grave\nAnd rose victorious in the strife\nFor those He came to save:\nHis glories now we sing,\nWho died and rose on high,\nWho died eternal life to bring\nAnd lives that death may die.\n", + "v" + ], + [ + "Crown Him the Lord of love;\nBehold His hands and side,\nThose wounds yet visible above\nIn beauty glorified:\nNo angel in the sky\nCan fully bear that sight,\nBut downward bends His burning eye\nAt mysteries so bright.\n", + "v" + ], + [ + "Crown Him the Lord of peace,\nWhose power a sceptre sways\nFrom pole to pole, that wars may cease,\nAnd all be prayer and praise:\nHis reign shall know no end,\nAnd round His piercèd feet\nFair flowers of paradise extend\nTheir fragrance ever sweet.\n", + "v" + ], + [ + "Crown Him the Lord of years,\nThe Potentate of time,\nCreator of the rolling spheres,\nIneffably sublime!\nAll hail, Redeemer, hail!\nFor Thou hast died for me;\nThy praise shall never, never fail\nThroughout eternity.\n", + "v" + ] + ] +} From fc5f2e101823f0c266e33897f00e2208a49cf17e Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 27 Oct 2015 15:00:11 +0000 Subject: [PATCH 4/7] Improve the worshipcenter pro importer and updated test. --- .../songs/lib/importers/worshipcenterpro.py | 37 ++++++++++++++++++- .../songs/test_worshipcenterproimport.py | 30 ++++++++++++--- 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/songs/lib/importers/worshipcenterpro.py b/openlp/plugins/songs/lib/importers/worshipcenterpro.py index 31352ad0e..cc1a96f8e 100644 --- a/openlp/plugins/songs/lib/importers/worshipcenterpro.py +++ b/openlp/plugins/songs/lib/importers/worshipcenterpro.py @@ -24,7 +24,7 @@ The :mod:`worshipcenterpro` module provides the functionality for importing a WorshipCenter Pro database into the OpenLP database. """ import logging - +import re import pyodbc from openlp.core.common import translate @@ -71,8 +71,41 @@ class WorshipCenterProImport(SongImport): break self.set_defaults() self.title = songs[song]['TITLE'] + if 'AUTHOR' in songs[song]: + self.parse_author(songs[song]['AUTHOR']) + if 'CCLISONGID' in songs[song]: + self.ccli_number = songs[song]['CCLISONGID'] + if 'COMMENTS' in songs[song]: + self.add_comment(songs[song]['COMMENTS']) + if 'COPY' in songs[song]: + self.add_copyright(songs[song]['COPY']) + if 'SUBJECT' in songs[song]: + self.topics.append(songs[song]['SUBJECT']) lyrics = songs[song]['LYRICS'].strip('&crlf;&crlf;') for verse in lyrics.split('&crlf;&crlf;'): verse = verse.replace('&crlf;', '\n') - self.add_verse(verse) + marker_type = 'v' + # Find verse markers if any + marker_start = verse.find('<') + if marker_start > -1: + marker_end = verse.find('>') + marker = verse[marker_start + 1:marker_end] + # Identify the marker type + if 'REFRAIN' in marker or 'CHORUS' in marker: + marker_type = 'c' + elif 'BRIDGE' in marker: + marker_type = 'b' + elif 'PRECHORUS' in marker: + marker_type = 'p' + elif 'END' in marker: + marker_type = 'e' + elif 'INTRO' in marker: + marker_type = 'i' + elif 'TAG' in marker: + marker_type = 'o' + else: + marker_type = 'v' + # Strip tags from text + verse = re.sub('<[^<]+?>', '', verse) + self.add_verse(verse, marker_type) self.finish() diff --git a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py index 5b7dde63d..849522e67 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py @@ -25,9 +25,6 @@ This module contains tests for the WorshipCenter Pro song importer. import os from unittest import TestCase, SkipTest -if os.name != 'nt': - raise SkipTest('Not Windows, skipping test') - import pyodbc from tests.functional import patch, MagicMock @@ -67,6 +64,10 @@ class WorshipCenterProImportLogger(WorshipCenterProImport): RECORDSET_TEST_DATA = [TestRecord(1, 'TITLE', 'Amazing Grace'), + TestRecord(1, 'AUTHOR', 'John Newton'), + TestRecord(1, 'CCLISONGID', '12345'), + TestRecord(1, 'COMMENTS', 'The original version'), + TestRecord(1, 'COPY', 'Public Domain'), TestRecord( 1, 'LYRICS', 'Amazing grace! How&crlf;sweet the sound&crlf;That saved a wretch like me!&crlf;' @@ -97,7 +98,9 @@ RECORDSET_TEST_DATA = [TestRecord(1, 'TITLE', 'Amazing Grace'), 'Just to learn from His&crlf;lips words of comfort&crlf;In the beautiful&crlf;' 'garden of prayer.&crlf;&crlf;There\'s a garden where&crlf;Jesus is waiting,&crlf;' 'And He bids you to come,&crlf;meet Him there;&crlf;Just to bow and&crlf;' - 'receive a new blessing&crlf;In the beautiful&crlf;garden of prayer.&crlf;&crlf;')] + 'receive a new blessing&crlf;In the beautiful&crlf;garden of prayer.&crlf;&crlf;'), + + ] SONG_TEST_DATA = [{'title': 'Amazing Grace', 'verses': [ ('Amazing grace! How\nsweet the sound\nThat saved a wretch like me!\nI once was lost,\n' @@ -113,7 +116,10 @@ SONG_TEST_DATA = [{'title': 'Amazing Grace', ('The earth shall soon\ndissolve like snow,\nThe sun forbear to shine;\nBut God, Who called\n' 'me here below,\nShall be forever mine.'), ('When we\'ve been there\nten thousand years,\nBright shining as the sun,\n' - 'We\'ve no less days to\nsing God\'s praise\nThan when we\'d first begun.')]}, + 'We\'ve no less days to\nsing God\'s praise\nThan when we\'d first begun.')], + 'author': 'John Newton', + 'comments': 'The original version', + 'copyright': 'Public Domain'}, {'title': 'Beautiful Garden Of Prayer, The', 'verses': [ ('There\'s a garden where\nJesus is waiting,\nThere\'s a place that\nis wondrously fair,\n' @@ -191,6 +197,9 @@ class TestWorshipCenterProSongImport(TestCase): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() mocked_add_verse = MagicMock() + mocked_parse_author= MagicMock() + mocked_add_comment = MagicMock() + mocked_add_copyright = MagicMock() mocked_finish = MagicMock() mocked_pyodbc.connect().cursor().fetchall.return_value = RECORDSET_TEST_DATA mocked_translate.return_value = 'Translated Text' @@ -198,6 +207,9 @@ class TestWorshipCenterProSongImport(TestCase): importer.import_source = 'import_source' importer.import_wizard = mocked_import_wizard importer.add_verse = mocked_add_verse + importer.parse_author = mocked_parse_author + importer.add_comment = mocked_add_comment + importer.add_copyright = mocked_add_copyright importer.stop_import_flag = False importer.finish = mocked_finish @@ -220,6 +232,12 @@ class TestWorshipCenterProSongImport(TestCase): verse_calls = song_data['verses'] add_verse_call_count += len(verse_calls) for call in verse_calls: - mocked_add_verse.assert_any_call(call) + mocked_add_verse.assert_any_call(call, 'v') + if 'author' in song_data: + mocked_parse_author.assert_any_call(song_data['author']) + if 'comments' in song_data: + mocked_add_comment.assert_any_call(song_data['comments']) + if 'copyright' in song_data: + mocked_add_copyright.assert_any_call(song_data['copyright']) self.assertEqual(mocked_add_verse.call_count, add_verse_call_count, 'Incorrect number of calls made to add_verse') From a8c5f8cb522dc1638386f0e4f1c7bbb755b8eb71 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 27 Oct 2015 15:15:22 +0000 Subject: [PATCH 5/7] Make test windows-only, again. --- .../openlp_plugins/songs/test_worshipcenterproimport.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py index 849522e67..cf5ba6bda 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py @@ -25,6 +25,9 @@ This module contains tests for the WorshipCenter Pro song importer. import os from unittest import TestCase, SkipTest +if os.name != 'nt': + raise SkipTest('Not Windows, skipping test') + import pyodbc from tests.functional import patch, MagicMock From f712b35b08cdf0c48705573f793f7becb7c29c41 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 27 Oct 2015 22:36:52 +0000 Subject: [PATCH 6/7] pep8 fixes --- .../songs/test_worshipcenterproimport.py | 12 +++++------- .../openlp_plugins/songs/test_zionworximport.py | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py index cf5ba6bda..98280f06a 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py @@ -101,9 +101,7 @@ RECORDSET_TEST_DATA = [TestRecord(1, 'TITLE', 'Amazing Grace'), 'Just to learn from His&crlf;lips words of comfort&crlf;In the beautiful&crlf;' 'garden of prayer.&crlf;&crlf;There\'s a garden where&crlf;Jesus is waiting,&crlf;' 'And He bids you to come,&crlf;meet Him there;&crlf;Just to bow and&crlf;' - 'receive a new blessing&crlf;In the beautiful&crlf;garden of prayer.&crlf;&crlf;'), - - ] + 'receive a new blessing&crlf;In the beautiful&crlf;garden of prayer.&crlf;&crlf;')] SONG_TEST_DATA = [{'title': 'Amazing Grace', 'verses': [ ('Amazing grace! How\nsweet the sound\nThat saved a wretch like me!\nI once was lost,\n' @@ -120,9 +118,9 @@ SONG_TEST_DATA = [{'title': 'Amazing Grace', 'me here below,\nShall be forever mine.'), ('When we\'ve been there\nten thousand years,\nBright shining as the sun,\n' 'We\'ve no less days to\nsing God\'s praise\nThan when we\'d first begun.')], - 'author': 'John Newton', - 'comments': 'The original version', - 'copyright': 'Public Domain'}, + 'author': 'John Newton', + 'comments': 'The original version', + 'copyright': 'Public Domain'}, {'title': 'Beautiful Garden Of Prayer, The', 'verses': [ ('There\'s a garden where\nJesus is waiting,\nThere\'s a place that\nis wondrously fair,\n' @@ -200,7 +198,7 @@ class TestWorshipCenterProSongImport(TestCase): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() mocked_add_verse = MagicMock() - mocked_parse_author= MagicMock() + mocked_parse_author = MagicMock() mocked_add_comment = MagicMock() mocked_add_copyright = MagicMock() mocked_finish = MagicMock() diff --git a/tests/functional/openlp_plugins/songs/test_zionworximport.py b/tests/functional/openlp_plugins/songs/test_zionworximport.py index 0e7ba16da..c2ef0ff48 100644 --- a/tests/functional/openlp_plugins/songs/test_zionworximport.py +++ b/tests/functional/openlp_plugins/songs/test_zionworximport.py @@ -35,6 +35,7 @@ from openlp.core.common import Registry TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'zionworxsongs')) + class TestZionWorxImport(TestCase): """ Test the functions in the :mod:`zionworximport` module. @@ -59,6 +60,7 @@ class TestZionWorxImport(TestCase): # THEN: The importer should be an instance of SongImport self.assertIsInstance(importer, SongImport) + class TestZionWorxFileImport(SongImportTestHelper): def __init__(self, *args, **kwargs): From 05043edb6d002972695713cfc961e6897346a671 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 28 Oct 2015 16:43:17 +0000 Subject: [PATCH 7/7] Strip trailing whitespaces from verse-string. --- openlp/plugins/songs/lib/importers/worshipcenterpro.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/importers/worshipcenterpro.py b/openlp/plugins/songs/lib/importers/worshipcenterpro.py index cc1a96f8e..4bf2c0f02 100644 --- a/openlp/plugins/songs/lib/importers/worshipcenterpro.py +++ b/openlp/plugins/songs/lib/importers/worshipcenterpro.py @@ -107,5 +107,5 @@ class WorshipCenterProImport(SongImport): marker_type = 'v' # Strip tags from text verse = re.sub('<[^<]+?>', '', verse) - self.add_verse(verse, marker_type) + self.add_verse(verse.strip(), marker_type) self.finish()