forked from openlp/openlp
Started work on tests
This commit is contained in:
parent
98eb50e9b2
commit
51ffb92d40
@ -80,6 +80,17 @@ class OpsProImport(SongImport):
|
|||||||
def process_song(self, song, lyrics, topics):
|
def process_song(self, song, lyrics, topics):
|
||||||
"""
|
"""
|
||||||
Create the song, i.e. title, verse etc.
|
Create the song, i.e. title, verse etc.
|
||||||
|
|
||||||
|
The OPS Pro format is a fairly simple text format using tags and anchors/labels. Linebreaks are \r\n.
|
||||||
|
Double linebreaks are slide dividers. OPS Pro support dual language using tags.
|
||||||
|
Tags are in [], see the liste below:
|
||||||
|
[join] are used to separate verses that should be keept on the same slide.
|
||||||
|
[split] or [splits] can be used to split a verse over several slides, while still being the same verse
|
||||||
|
Dual language tags:
|
||||||
|
[trans off] or [vertaal uit] turns dual language mode off for the following text
|
||||||
|
[trans on] or [vertaal aan] turns dual language mode on for the following text
|
||||||
|
[taal a] means the following lines are language a
|
||||||
|
[taal b] means the following lines are language b
|
||||||
"""
|
"""
|
||||||
self.set_defaults()
|
self.set_defaults()
|
||||||
self.title = song.Title
|
self.title = song.Title
|
||||||
|
@ -30,6 +30,7 @@ from tests.functional import patch, MagicMock
|
|||||||
from openlp.core.common import Registry
|
from openlp.core.common import Registry
|
||||||
from openlp.plugins.songs.lib.importers.opspro import OpsProImport
|
from openlp.plugins.songs.lib.importers.opspro import OpsProImport
|
||||||
|
|
||||||
|
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'opsprosongs'))
|
||||||
|
|
||||||
class TestRecord(object):
|
class TestRecord(object):
|
||||||
"""
|
"""
|
||||||
@ -43,74 +44,6 @@ class TestRecord(object):
|
|||||||
self.Field = field
|
self.Field = field
|
||||||
self.Value = value
|
self.Value = value
|
||||||
|
|
||||||
SONG_TEST_DATA1 = ('Refrein 2x:\r\n'
|
|
||||||
'Kom zing een nieuw lied\r\n'
|
|
||||||
'want dit is een nieuwe dag.\r\n'
|
|
||||||
'Zet de poorten open en zing je lied voor Hem.\r\n'
|
|
||||||
'[splits]\r\n'
|
|
||||||
'Kom zing een nieuw lied\r\n'
|
|
||||||
'Hij heeft je roep gehoord.\r\n'
|
|
||||||
'En de trouw en liefde van God zijn ook voor jou!\r\n'
|
|
||||||
' \r\n'
|
|
||||||
'Hij glimlacht en schijnt zijn licht op ons.\r\n'
|
|
||||||
'Hij redt ons en steunt ons liefdevol.\r\n'
|
|
||||||
'Mijn Redder, mijn sterkte is de Heer.\r\n'
|
|
||||||
'Deze dag leef ik voor Hem - en geef Hem eer!\r\n'
|
|
||||||
' \r\n'
|
|
||||||
'(refrein)\r\n'
|
|
||||||
'\r\n'
|
|
||||||
'Zijn goedheid rust elke dag op ons.\r\n'
|
|
||||||
'Zijn liefde verdrijft de angst in ons.\r\n'
|
|
||||||
'Mijn schuilplaats, mijn toevlucht is de Heer.\r\n'
|
|
||||||
'Deze dag leef ik voor Hem - en geef Hem eer!\r\n'
|
|
||||||
' \r\n'
|
|
||||||
'(refrein)\r\n'
|
|
||||||
'\r\n'
|
|
||||||
'Bridge 3x:\r\n'
|
|
||||||
'Breng dank aan de Heer jouw God.\r\n'
|
|
||||||
'Geef eer met een dankbaar hart,\r\n'
|
|
||||||
'Hij toont zijn liefde hier vandaag!\r\n'
|
|
||||||
'[splits]\r\n'
|
|
||||||
'Breng dank aan de Heer, jouw God.\r\n'
|
|
||||||
'Geef eer met een dankbaar hart.\r\n'
|
|
||||||
'Open je hart voor Hem vandaag!\r\n'
|
|
||||||
'\r\n'
|
|
||||||
'Ik zing een nieuw lied en breng Hem de hoogste eer\r\n'
|
|
||||||
'want de nieuwe dag is vol zegen van de Heer!\r\n'
|
|
||||||
'Ik zing een nieuw lied en breng Hem de hoogste eer.\r\n'
|
|
||||||
'Zet je hart wijd open en zing je lied voor Hem!\r\n')
|
|
||||||
|
|
||||||
|
|
||||||
SONG_TEST_DATA = [{'title': 'Amazing Grace',
|
|
||||||
'verses': [
|
|
||||||
('Amazing grace! How\nsweet the sound\nThat saved a wretch like me!\nI once was lost,\n'
|
|
||||||
'but now am found;\nWas blind, but now I see.'),
|
|
||||||
('\'Twas grace that\ntaught my heart to fear,\nAnd grace my fears relieved;\nHow precious did\n'
|
|
||||||
'that grace appear\nThe hour I first believed.'),
|
|
||||||
('Through many dangers,\ntoils and snares,\nI have already come;\n\'Tis grace hath brought\n'
|
|
||||||
'me safe thus far,\nAnd grace will lead me home.'),
|
|
||||||
('The Lord has\npromised good to me,\nHis Word my hope secures;\n'
|
|
||||||
'He will my Shield\nand Portion be,\nAs long as life endures.'),
|
|
||||||
('Yea, when this flesh\nand heart shall fail,\nAnd mortal life shall cease,\nI shall possess,\n'
|
|
||||||
'within the veil,\nA life of joy and peace.'),
|
|
||||||
('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.')],
|
|
||||||
'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'
|
|
||||||
'For it glows with the\nlight of His presence.\n\'Tis the beautiful\ngarden of prayer.'),
|
|
||||||
('Oh, the beautiful garden,\nthe garden of prayer!\nOh, the beautiful\ngarden of prayer!\n'
|
|
||||||
'There my Savior awaits,\nand He opens the gates\nTo the beautiful\ngarden of prayer.'),
|
|
||||||
('There\'s a garden where\nJesus is waiting,\nAnd I go with my\nburden and care,\n'
|
|
||||||
'Just to learn from His\nlips words of comfort\nIn the beautiful\ngarden of prayer.'),
|
|
||||||
('There\'s a garden where\nJesus is waiting,\nAnd He bids you to come,\nmeet Him there;\n'
|
|
||||||
'Just to bow and\nreceive a new blessing\nIn the beautiful\ngarden of prayer.')]}]
|
|
||||||
|
|
||||||
|
|
||||||
class TestOpsProSongImport(TestCase):
|
class TestOpsProSongImport(TestCase):
|
||||||
"""
|
"""
|
||||||
@ -153,7 +86,8 @@ class TestOpsProSongImport(TestCase):
|
|||||||
song.Version = '1'
|
song.Version = '1'
|
||||||
song.Origin = '...'
|
song.Origin = '...'
|
||||||
lyrics = MagicMock()
|
lyrics = MagicMock()
|
||||||
lyrics.Lyrics = SONG_TEST_DATA1
|
test_file = open(os.path.join(TEST_PATH, 'you are so faithfull.txt'), 'rb')
|
||||||
|
lyrics.Lyrics = test_file.read().decode()
|
||||||
lyrics.Type = 1
|
lyrics.Type = 1
|
||||||
lyrics.IsDualLanguage = True
|
lyrics.IsDualLanguage = True
|
||||||
importer.finish = MagicMock()
|
importer.finish = MagicMock()
|
||||||
|
37
tests/resources/opsprosongs/you are so faithfull.txt
Normal file
37
tests/resources/opsprosongs/you are so faithfull.txt
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
1
|
||||||
|
You are so faithful
|
||||||
|
so faithful, so faithful.
|
||||||
|
You are so faithful
|
||||||
|
so faithful, so faithful.
|
||||||
|
|
||||||
|
Refrein:
|
||||||
|
That's why I praise you
|
||||||
|
in the morning
|
||||||
|
That's why I praise you
|
||||||
|
in the noontime.
|
||||||
|
That's why I praise you
|
||||||
|
in the evening
|
||||||
|
That's why I praise you
|
||||||
|
all the time.
|
||||||
|
|
||||||
|
2
|
||||||
|
You are so loving
|
||||||
|
so loving, so loving.
|
||||||
|
You are so loving
|
||||||
|
so loving, so loving.
|
||||||
|
|
||||||
|
(refrein)
|
||||||
|
|
||||||
|
3
|
||||||
|
You are so caring
|
||||||
|
so caring, so caring.
|
||||||
|
You are so caring
|
||||||
|
so caring, so caring.
|
||||||
|
|
||||||
|
(refrein)
|
||||||
|
|
||||||
|
4
|
||||||
|
You are so mighty
|
||||||
|
so mighty, so mighty.
|
||||||
|
You are so mighty
|
||||||
|
so mighty, so mighty.
|
Loading…
Reference in New Issue
Block a user