From 51f4539822b837464cfb62f69d07600cb5d2eaf7 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 3 Nov 2014 15:36:27 +0100 Subject: [PATCH] Added test for Word of Worship import --- .../songs/lib/importers/wordsofworship.py | 2 +- .../songs/test_wordsofworshipimport.py | 54 ++++++++++++++++++ .../Amazing Grace (6 Verses).json | 33 +++++++++++ .../Amazing Grace (6 Verses).wow-song | Bin 0 -> 965 bytes 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 tests/functional/openlp_plugins/songs/test_wordsofworshipimport.py create mode 100644 tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).json create mode 100644 tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).wow-song diff --git a/openlp/plugins/songs/lib/importers/wordsofworship.py b/openlp/plugins/songs/lib/importers/wordsofworship.py index 8fcbc9f84..29b384085 100644 --- a/openlp/plugins/songs/lib/importers/wordsofworship.py +++ b/openlp/plugins/songs/lib/importers/wordsofworship.py @@ -99,7 +99,7 @@ class WordsOfWorshipImport(SongImport): """ Initialise the Words of Worship importer. """ - SongImport.__init__(self, manager, **kwargs) + super(WordsOfWorshipImport, self).__init__(manager, **kwargs) def do_import(self): """ diff --git a/tests/functional/openlp_plugins/songs/test_wordsofworshipimport.py b/tests/functional/openlp_plugins/songs/test_wordsofworshipimport.py new file mode 100644 index 000000000..952e16971 --- /dev/null +++ b/tests/functional/openlp_plugins/songs/test_wordsofworshipimport.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +This module contains tests for the Words of Worship song importer. +""" + +import os + +from tests.helpers.songfileimport import SongImportTestHelper +from openlp.plugins.songs.lib.importers.wordsofworship import WordsOfWorshipImport + +TEST_PATH = os.path.abspath( + os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'wordsofworshipsongs')) + + +class TestWordsOfWorshipFileImport(SongImportTestHelper): + + def __init__(self, *args, **kwargs): + self.importer_class_name = 'WordsOfWorshipImport' + self.importer_module_name = 'wordsofworship' + super(TestWordsOfWorshipFileImport, self).__init__(*args, **kwargs) + + def test_song_import(self): + """ + Test that loading a Words of Worship file works correctly + """ + self.file_import([os.path.join(TEST_PATH, 'Amazing Grace (6 Verses).wow-song')], + self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace (6 Verses).json'))) diff --git a/tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).json b/tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).json new file mode 100644 index 000000000..563872ae7 --- /dev/null +++ b/tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).json @@ -0,0 +1,33 @@ +{ + "authors": [ + "John Newton (1725-1807)" + ], + "title": "Amazing Grace (6 Verses)", + "verse_order_list": [], + "verses": [ + [ + "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.", + "V" + ], + [ + "'Twas grace that taught my heart to fear,\nAnd grace my fears relieved;\nHow precious did that grace appear,\nThe hour I first believed!", + "V" + ], + [ + "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.", + "V" + ], + [ + "The Lord has promised good to me,\nHis word my hope secures;\nHe will my shield and portion be\nAs long as life endures.", + "V" + ], + [ + "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.", + "V" + ], + [ + "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.", + "V" + ] + ] +} diff --git a/tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).wow-song b/tests/resources/wordsofworshipsongs/Amazing Grace (6 Verses).wow-song new file mode 100644 index 0000000000000000000000000000000000000000..e45d22e2ffa3dcfafa966ae5984e40bc78698536 GIT binary patch literal 965 zcmZ9L&1)1v5XC$3Q&8L=JeSI-uWSMNpneM-q|+BY+>nB*JCXGJsKY70iOEq_IBGm zF_(JtlN4uXmlr{b>xYOOp4axbhu|{Vf)B_^N4aBesBuhL+E|+XnX?ULd&4DJ>Jm4F zqu{TZYMz+GDM>7tI-4m-ZpO4|8;a1eHB~AwHoJ2K7r|qHADvQWe%FI;{ZW*o(M&aZ z5M)Qn#P`xI{HsQZeh0WOPpU3j$*~RC8d_&Uv*;%%6fO_^-T%_;ZHE{Ix@#%+? Nx5ppfpC0ue<6q+@B>eyY literal 0 HcmV?d00001