~suutari-olli/openlp/click-slide-to-go-live-from-blank

« back to all changes in this revision

Viewing changes to tests/functional/openlp_plugins/songs/test_lib.py

"Fix traceback when searching for book that doesn't exists in second bible. Fixes bug 1553863.
Set progress bar steps to number of chapters in zefania import.
Use standard button text in the FTW, if possible. Fixes bug 1554554.
Translation fixes. Fixes bug 1545072
Fix song tag detection. Fixes bug 1549549.
Fix a method call with too many parentheses, which fixes getting bible books from crosswalk."

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
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
30
30
 
31
31
 
32
32
class TestLib(TestCase):
477
477
 
478
478
            # THEN: The result should be None
479
479
            self.assertIsNone(result, 'The result should be None, but was "%s"' % result)
 
480
 
 
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):
 
483
        """
 
484
        Test that the from_loose_input() method returns a sane default when passed an invalid tag and None as default.
 
485
        """
 
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)
 
489
 
 
490
        # THEN: The result should be None
 
491
        self.assertIsNone(result, 'The result should be None, but was "%s"' % result)
 
492
 
 
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):
 
495
        """
 
496
        Test that the from_loose_input() method returns valid output on valid input.
 
497
        """
 
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')
 
501
 
 
502
        # THEN: The result should be a Verse
 
503
        self.assertEqual(result, VerseType.Verse, 'The result should be a verse, but was "%s"' % result)