~trb143/openlp/bug-1516171-24

« back to all changes in this revision

Viewing changes to tests/functional/openlp_plugins/bibles/test_osisimport.py

  • Committer: Raoul Snyman
  • Author(s): Tomas Groth
  • Date: 2015-07-14 19:59:15 UTC
  • mfrom: (2545.1.2 py33fix)
  • Revision ID: raoul@snyman.info-20150714195915-1p4ckhkjju5uik7u
Revert changes to support python 3.5 to make sure we support python 3.3.
Fix traceback in OSIS import on empty verse tag.

Show diffs side-by-side

added added

removed removed

Lines of Context:
152
152
            self.assertTrue(importer.create_verse.called)
153
153
            for verse_tag, verse_text in test_data['verses']:
154
154
                importer.create_verse.assert_any_call(importer.create_book().id, '1', verse_tag, verse_text)
 
155
 
 
156
    def file_import_empty_verse_tags_test(self):
 
157
        """
 
158
        Test the actual import of OSIS Bible file, with an empty verse tags.
 
159
        """
 
160
        # GIVEN: Test files with a mocked out "manager", "import_wizard", and mocked functions
 
161
        #        get_book_ref_id_by_name, create_verse, create_book, session and get_language.
 
162
        result_file = open(os.path.join(TEST_PATH, 'dk1933.json'), 'rb')
 
163
        test_data = json.loads(result_file.read().decode())
 
164
        bible_file = 'osis-dk1933-empty-verse.xml'
 
165
        with patch('openlp.plugins.bibles.lib.osis.OSISBible.application'):
 
166
            mocked_manager = MagicMock()
 
167
            mocked_import_wizard = MagicMock()
 
168
            importer = OSISBible(mocked_manager, path='.', name='.', filename='')
 
169
            importer.wizard = mocked_import_wizard
 
170
            importer.get_book_ref_id_by_name = MagicMock()
 
171
            importer.create_verse = MagicMock()
 
172
            importer.create_book = MagicMock()
 
173
            importer.session = MagicMock()
 
174
            importer.get_language = MagicMock()
 
175
            importer.get_language.return_value = 'Danish'
 
176
 
 
177
            # WHEN: Importing bible file
 
178
            importer.filename = os.path.join(TEST_PATH, bible_file)
 
179
            importer.do_import()
 
180
 
 
181
            # THEN: The create_verse() method should have been called with each verse in the file.
 
182
            self.assertTrue(importer.create_verse.called)
 
183
            for verse_tag, verse_text in test_data['verses']:
 
184
                importer.create_verse.assert_any_call(importer.create_book().id, '1', verse_tag, verse_text)