Exemplo n.º 1
0
    def test_process_chapters_milestones_chapter_no_sid(self):
        """
        Test process_chapters when supplied with an etree element with a chapter and verse element in the milestone
        configuration, where the chapter is the "closing" milestone. (Missing the sID attribute)
        """
        with patch('openlp.plugins.bibles.lib.importers.osis.verse_in_chapter', return_value=False), \
                patch.object(OSISBible, 'set_current_chapter') as mocked_set_current_chapter, \
                patch.object(OSISBible, 'process_verse') as mocked_process_verse:

            # GIVEN: Some test data and an instance of OSISBible
            test_book = MagicMock()
            test_chapter = MagicMock()
            test_chapter.tag = '{http://www.bibletechnologies.net/2003/OSIS/namespace}chapter'
            test_chapter.get.side_effect = lambda x: {'osisID': '1.2.4'}.get(x)

            # WHEN: Calling process_chapters
            importer = OSISBible(MagicMock(),
                                 path='.',
                                 name='.',
                                 file_path=None)
            importer.process_chapters(test_book, [test_chapter])

            # THEN: neither set_current_chapter or process_verse should have been called
            assert mocked_set_current_chapter.called is False
            assert mocked_process_verse.called is False
Exemplo n.º 2
0
    def test_process_chapters_milestones_verse_tag(self):
        """
        Test process_chapters when supplied with an etree element with a chapter and verse element in the milestone
        configuration, where the verse is the "opening" milestone. (Has the sID attribute)
        """
        with patch('openlp.plugins.bibles.lib.importers.osis.verse_in_chapter', return_value=False), \
                patch.object(OSISBible, 'set_current_chapter') as mocked_set_current_chapter, \
                patch.object(OSISBible, 'process_verse') as mocked_process_verse:

            # GIVEN: Some test data and an instance of OSISBible
            test_book = MagicMock()
            test_verse = MagicMock()
            test_verse.get.side_effect = lambda x: {
                'osisID': '1.2.4',
                'sID': '999'
            }.get(x)
            test_verse.tag = '{http://www.bibletechnologies.net/2003/OSIS/namespace}verse'
            test_verse.tail = '\n    '  # Whitespace
            test_verse.text = 'Verse Text'

            # WHEN: Calling process_chapters
            importer = OSISBible(MagicMock(),
                                 path='.',
                                 name='.',
                                 file_path=None)
            importer.process_chapters(test_book, [test_verse])

            # THEN: process_verse should have been called with the test data
            assert mocked_set_current_chapter.called is False
            mocked_process_verse.assert_called_once_with(test_book,
                                                         0,
                                                         test_verse,
                                                         use_milestones=True)
Exemplo n.º 3
0
    def test_process_chapters_verse_in_chapter_verse_text(self):
        """
        Test process_chapters when supplied with an etree element with a verse element nested in it
        """
        with patch('openlp.plugins.bibles.lib.importers.osis.verse_in_chapter', return_value=True), \
                patch('openlp.plugins.bibles.lib.importers.osis.text_in_verse', return_value=True), \
                patch.object(OSISBible, 'set_current_chapter') as mocked_set_current_chapter, \
                patch.object(OSISBible, 'process_verse') as mocked_process_verse:

            # GIVEN: Some test data and an instance of OSISBible
            test_book = MagicMock()
            test_verse = MagicMock()
            test_verse.tail = '\n    '  # Whitespace
            test_verse.text = 'Verse Text'
            test_chapter = MagicMock()
            test_chapter.__iter__.return_value = [test_verse]
            test_chapter.get.side_effect = lambda x: {
                'osisID': '1.2.4',
                'sID': '999'
            }.get(x)
            importer = OSISBible(MagicMock(),
                                 path='.',
                                 name='.',
                                 file_path=None)

            # WHEN: Calling process_chapters
            importer.process_chapters(test_book, [test_chapter])

            # THEN: set_current_chapter and process_verse should have been called with the test data
            mocked_set_current_chapter.assert_called_once_with(
                test_book.name, 2)
            mocked_process_verse.assert_called_once_with(
                test_book, 2, test_verse)