forked from openlp/openlp
Songbeamer-import: added check_verse_marks_test to test the correct detection of different lines that may occur
This commit is contained in:
parent
69500907c0
commit
0293815135
@ -35,6 +35,7 @@ from unittest import TestCase
|
||||
|
||||
from tests.functional import MagicMock, patch
|
||||
from openlp.plugins.songs.lib.songbeamerimport import SongBeamerImport
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
|
||||
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'..', '..', '..', 'resources', 'songbeamersongs'))
|
||||
@ -153,3 +154,80 @@ class TestSongBeamerImport(TestCase):
|
||||
self.assertEquals(importer.song_number, song_number, 'song_number for %s should be %s' %
|
||||
(song_file, song_number))
|
||||
mocked_finish.assert_called_with()
|
||||
|
||||
def check_verse_marks_test(self):
|
||||
"""
|
||||
Tests different lines to see if a verse mark is detected or not
|
||||
"""
|
||||
|
||||
# GIVEN: line with unnumbered verse-type
|
||||
line = 'Refrain'
|
||||
self.current_verse_type = None
|
||||
# WHEN: line is being checked for verse marks
|
||||
result = SongBeamerImport.check_verse_marks(self, line)
|
||||
# THEN: we should get back true and c as self.current_verse_type
|
||||
assert result is True, u'Versemark for <Refrain> should be found, value true'
|
||||
assert self.current_verse_type == 'c', u'<Refrain> should be interpreted as <c>'
|
||||
|
||||
# GIVEN: line with unnumbered verse-type and trailing space
|
||||
line = 'Refrain '
|
||||
self.current_verse_type = None
|
||||
# WHEN: line is being checked for verse marks
|
||||
result = SongBeamerImport.check_verse_marks(self, line)
|
||||
# THEN: we should get back true and c as self.current_verse_type
|
||||
assert result is True, u'Versemark for <Refrain > should be found, value true'
|
||||
assert self.current_verse_type == 'c', u'<Refrain > should be interpreted as <c>'
|
||||
|
||||
# GIVEN: line with numbered verse-type
|
||||
line = 'Verse 1'
|
||||
self.current_verse_type = None
|
||||
# WHEN: line is being checked for verse marks
|
||||
result = SongBeamerImport.check_verse_marks(self, line)
|
||||
# THEN: we should get back true and v1 as self.current_verse_type
|
||||
assert result is True, u'Versemark for <Verse 1> should be found, value true'
|
||||
assert self.current_verse_type == 'v1', u'<Verse 1> should be interpreted as <v1>'
|
||||
|
||||
# GIVEN: line with special unnumbered verse-mark (used in Songbeamer to allow usage of non-supported tags)
|
||||
line = '$$M=special'
|
||||
self.current_verse_type = None
|
||||
# WHEN: line is being checked for verse marks
|
||||
result = SongBeamerImport.check_verse_marks(self, line)
|
||||
# THEN: we should get back true and o as self.current_verse_type
|
||||
assert result is True, u'Versemark for <$$M=special> should be found, value true'
|
||||
assert self.current_verse_type == 'o', u'<$$M=special> should be interpreted as <o>'
|
||||
|
||||
# GIVEN: line with song-text with 3 words
|
||||
line = 'Jesus my saviour'
|
||||
self.current_verse_type = None
|
||||
# WHEN: line is being checked for verse marks
|
||||
result = SongBeamerImport.check_verse_marks(self, line)
|
||||
# THEN: we should get back false and none as self.current_verse_type
|
||||
assert result is False, u'No versemark for <Jesus my saviour> should be found, value false'
|
||||
assert self.current_verse_type is None, u'<Jesus my saviour> should be interpreted as none versemark'
|
||||
|
||||
# GIVEN: line with song-text with 2 words
|
||||
line = 'Praise him'
|
||||
self.current_verse_type = None
|
||||
# WHEN: line is being checked for verse marks
|
||||
result = SongBeamerImport.check_verse_marks(self, line)
|
||||
# THEN: we should get back false and none as self.current_verse_type
|
||||
assert result is False, u'No versemark for <Praise him> should be found, value false'
|
||||
assert self.current_verse_type is None, u'<Praise him> should be interpreted as none versemark'
|
||||
|
||||
# GIVEN: line with only a space (could occur, nothing regular)
|
||||
line = ' '
|
||||
self.current_verse_type = None
|
||||
# WHEN: line is being checked for verse marks
|
||||
result = SongBeamerImport.check_verse_marks(self, line)
|
||||
# THEN: we should get back false and none as self.current_verse_type
|
||||
assert result is False, u'No versemark for < > should be found, value false'
|
||||
assert self.current_verse_type is None, u'< > should be interpreted as none versemark'
|
||||
|
||||
# GIVEN: blank line (could occur, nothing regular)
|
||||
line = ''
|
||||
self.current_verse_type = None
|
||||
# WHEN: line is being checked for verse marks
|
||||
result = SongBeamerImport.check_verse_marks(self, line)
|
||||
# THEN: we should get back false and none as self.current_verse_type
|
||||
assert result is False, u'No versemark for <> should be found, value false'
|
||||
assert self.current_verse_type is None, u'<> should be interpreted as none versemark'
|
||||
|
Loading…
Reference in New Issue
Block a user