27
27
from openlp.plugins.songs.lib import VerseType, clean_string, clean_title, strip_rtf
28
28
from openlp.plugins.songs.lib.songcompare import songs_probably_equal, _remove_typos, _op_length
29
from tests.functional import patch, MagicMock
29
from tests.functional import patch, MagicMock, PropertyMock
32
32
class TestLib(TestCase):
478
478
# THEN: The result should be None
479
479
self.assertIsNone(result, 'The result should be None, but was "%s"' % result)
481
@patch('openlp.plugins.songs.lib.VerseType.translated_tags', new_callable=PropertyMock, return_value=['x'])
482
def from_loose_input_with_invalid_input_test(self, mocked_translated_tags):
484
Test that the from_loose_input() method returns a sane default when passed an invalid tag and None as default.
486
# GIVEN: A mocked VerseType.translated_tags
487
# WHEN: We run the from_loose_input() method with an invalid verse type, we get the specified default back
488
result = VerseType.from_loose_input('m', None)
490
# THEN: The result should be None
491
self.assertIsNone(result, 'The result should be None, but was "%s"' % result)
493
@patch('openlp.plugins.songs.lib.VerseType.translated_tags', new_callable=PropertyMock, return_value=['x'])
494
def from_loose_input_with_valid_input_test(self, mocked_translated_tags):
496
Test that the from_loose_input() method returns valid output on valid input.
498
# GIVEN: A mocked VerseType.translated_tags
499
# WHEN: We run the from_loose_input() method with a valid verse type, we get the expected VerseType back
500
result = VerseType.from_loose_input('v')
502
# THEN: The result should be a Verse
503
self.assertEqual(result, VerseType.Verse, 'The result should be a verse, but was "%s"' % result)