Add tests for ignored case

This commit is contained in:
Simon Hanna 2016-01-10 01:34:53 +01:00
parent 9525453679
commit 0f1d6718bd
2 changed files with 20 additions and 8 deletions

View File

@ -28,7 +28,7 @@ from unittest import TestCase
from tests.helpers.songfileimport import SongImportTestHelper from tests.helpers.songfileimport import SongImportTestHelper
from tests.functional import MagicMock, patch from tests.functional import MagicMock, patch
from openlp.plugins.songs.lib.importers.songbeamer import SongBeamerImport from openlp.plugins.songs.lib.importers.songbeamer import SongBeamerImport, SongBeamerTypes
from openlp.core.common import Registry from openlp.core.common import Registry
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__),
@ -131,22 +131,22 @@ class TestSongBeamerImport(TestCase):
self.assertEqual(self.current_verse_type, 'c', '<Refrain> should be interpreted as <c>') self.assertEqual(self.current_verse_type, 'c', '<Refrain> should be interpreted as <c>')
# GIVEN: line with unnumbered verse-type and trailing space # GIVEN: line with unnumbered verse-type and trailing space
line = 'Refrain ' line = 'ReFrain '
self.current_verse_type = None self.current_verse_type = None
# WHEN: line is being checked for verse marks # WHEN: line is being checked for verse marks
result = SongBeamerImport.check_verse_marks(self, line) result = SongBeamerImport.check_verse_marks(self, line)
# THEN: we should get back true and c as self.current_verse_type # THEN: we should get back true and c as self.current_verse_type
self.assertTrue(result, 'Versemark for <Refrain > should be found, value true') self.assertTrue(result, 'Versemark for <ReFrain > should be found, value true')
self.assertEqual(self.current_verse_type, 'c', '<Refrain > should be interpreted as <c>') self.assertEqual(self.current_verse_type, 'c', '<ReFrain > should be interpreted as <c>')
# GIVEN: line with numbered verse-type # GIVEN: line with numbered verse-type
line = 'Verse 1' line = 'VersE 1'
self.current_verse_type = None self.current_verse_type = None
# WHEN: line is being checked for verse marks # WHEN: line is being checked for verse marks
result = SongBeamerImport.check_verse_marks(self, line) result = SongBeamerImport.check_verse_marks(self, line)
# THEN: we should get back true and v1 as self.current_verse_type # THEN: we should get back true and v1 as self.current_verse_type
self.assertTrue(result, 'Versemark for <Verse 1> should be found, value true') self.assertTrue(result, 'Versemark for <VersE 1> should be found, value true')
self.assertEqual(self.current_verse_type, 'v1', u'<Verse 1> should be interpreted as <v1>') self.assertEqual(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) # GIVEN: line with special unnumbered verse-mark (used in Songbeamer to allow usage of non-supported tags)
line = '$$M=special' line = '$$M=special'
@ -192,3 +192,12 @@ class TestSongBeamerImport(TestCase):
# THEN: we should get back false and none as self.current_verse_type # THEN: we should get back false and none as self.current_verse_type
self.assertFalse(result, 'No versemark for <> should be found, value false') self.assertFalse(result, 'No versemark for <> should be found, value false')
self.assertIsNone(self.current_verse_type, '<> should be interpreted as none versemark') self.assertIsNone(self.current_verse_type, '<> should be interpreted as none versemark')
def test_verse_marks_defined_in_lowercase(self):
"""
Test that the verse marks are all defined in lowercase
"""
# GIVEN: SongBeamber MarkTypes
for tag in SongBeamerTypes.MarkTypes.keys():
# THEN: tag should be defined in lowercase
self.assertEquals(tag, tag.lower(), 'Tags should be defined in lowercase')

View File

@ -87,5 +87,8 @@ class TestSongFormat(TestCase):
Test that get_format_list() returns a list that is ordered Test that get_format_list() returns a list that is ordered
according to the order specified in SongFormat according to the order specified in SongFormat
""" """
# GIVEN: The SongFormat class
# WHEN: Retrieving all formats
# THEN: The returned list should be sorted according to the ordering defined in SongFormat
self.assertEquals(sorted(SongFormat.get_format_list()), SongFormat.get_format_list(), self.assertEquals(sorted(SongFormat.get_format_list()), SongFormat.get_format_list(),
"The list returned should be sorted according to the ordering in SongFormat") "The list returned should be sorted according to the ordering in SongFormat")