Beispiel #1
0
    def test_process_verse_no_osis_id(self):
        """
        Test process_verse when the element supplied does not have and osisID attribute
        """
        # GIVEN: An instance of OSISBible, and some mocked test data
        test_book = MagicMock()
        test_verse = MagicMock()
        test_verse.get.side_effect = lambda x: {}.get(x)
        test_verse.tail = 'Verse Text'
        test_verse.text = None
        importer = OSISBible(MagicMock(), path='.', name='.', file_path=None)

        # WHEN: Calling process_verse with the test data
        importer.process_verse(test_book, 2, test_verse)

        # THEN: create_verse should not have been called
        assert self.mocked_create_verse.called is False
Beispiel #2
0
    def process_verse_use_milestones_no_s_id_test(self):
        """
        Test process_verse when called with use_milestones set to True, but the element supplied does not have and sID
        attribute
        """
        # GIVEN: An instance of OSISBible, and some mocked test data
        test_book = MagicMock()
        test_verse = MagicMock()
        test_verse.get.side_effect = lambda x: {}.get(x)
        test_verse.tail = 'Verse Text'
        test_verse.text = None
        importer = OSISBible(MagicMock(), path='.', name='.', filename='')

        # WHEN: Calling process_verse with the test data
        importer.process_verse(test_book, 2, test_verse)

        # THEN: create_verse should not have been called
        self.assertFalse(self.mocked_create_verse.called)
Beispiel #3
0
    def test_process_verse_use_milestones_no_tail(self):
        """
        Test process_verse when called with use_milestones set to True, but the element supplied does not have a 'tail'
        """
        # GIVEN: An instance of OSISBible, and some mocked test data
        test_book = MagicMock()
        test_verse = MagicMock()
        test_verse.tail = None
        test_verse.text = None
        test_verse.get.side_effect = lambda x: {
            'osisID': '1.2.4',
            'sID': '999'
        }.get(x)
        importer = OSISBible(MagicMock(), path='.', name='.', file_path=None)

        # WHEN: Calling process_verse with the test data
        importer.process_verse(test_book, 2, test_verse, use_milestones=True)

        # THEN: create_verse should not have been called
        assert self.mocked_create_verse.called is False
Beispiel #4
0
    def test_process_verse_success(self):
        """
        Test process_verse when called with an element with text set
        """
        # GIVEN: An instance of OSISBible, and some mocked test data
        test_book = MagicMock()
        test_book.id = 1
        test_verse = MagicMock()
        test_verse.tail = '\n    '  # Whitespace
        test_verse.text = 'Verse Text'
        test_verse.get.side_effect = lambda x: {
            'osisID': '1.2.4',
            'sID': '999'
        }.get(x)
        importer = OSISBible(MagicMock(), path='.', name='.', file_path=None)

        # WHEN: Calling process_verse with the test data
        importer.process_verse(test_book, 2, test_verse)

        # THEN: create_verse should have been called with the test data
        self.mocked_create_verse.assert_called_once_with(1, 2, 4, 'Verse Text')
Beispiel #5
0
    def test_process_verse_no_text(self):
        """
        Test process_verse when called with an empty verse element
        """
        # GIVEN: An instance of OSISBible, and some mocked test data
        test_book = MagicMock()
        test_book.id = 1
        test_verse = MagicMock()
        test_verse.tail = '\n    '  # Whitespace
        test_verse.text = None
        test_verse.get.side_effect = lambda x: {
            'osisID': '1.2.4',
            'sID': '999'
        }.get(x)
        importer = OSISBible(MagicMock(), path='.', name='.', file_path=None)

        # WHEN: Calling process_verse with the test data
        importer.process_verse(test_book, 2, test_verse)

        # THEN: create_verse should not have been called
        assert self.mocked_create_verse.called is False
Beispiel #6
0
    def process_verse_use_milestones_success_test(self):
        """
        Test process_verse when called with use_milestones set to True, and the verse element successfully imports
        """
        # GIVEN: An instance of OSISBible, and some mocked test data
        test_book = MagicMock()
        test_book.id = 1
        test_verse = MagicMock()
        test_verse.tail = 'Verse Text'
        test_verse.text = None
        test_verse.get.side_effect = lambda x: {
            'osisID': '1.2.4',
            'sID': '999'
        }.get(x)
        importer = OSISBible(MagicMock(), path='.', name='.', filename='')

        # WHEN: Calling process_verse with the test data
        importer.process_verse(test_book, 2, test_verse, use_milestones=True)

        # THEN: create_verse should have been called with the test data
        self.mocked_create_verse.assert_called_once_with(1, 2, 4, 'Verse Text')