示例#1
0
 def test_get_base_passage_lowercase_translation(self):
     bible = BaseExtractor(file_reading_function=yaml_file_interface.read,
                           file_extension=self.get_test_file_extension(),
                           translation='KJV',
                           default_directory=self.get_test_directory('KJV'))
     text1 = bible.get_passage('Ecclesiastes', 2, 26)
     bible.translation = 'kjv'
     text2 = bible.get_passage('Ecclesiastes', 2, 26)
     # Translations should be case insensitive under the hood
     self.assertEqual(text1, text2, 'Passages do not match')
示例#2
0
 def test_get_base_passage_range_with_file_path_param(self):
     bible = BaseExtractor(file_reading_function=yaml_file_interface.read,
                           file_extension=self.get_test_file_extension(),
                           default_directory=self.get_test_directory(),
                           translation=self.get_test_translation())
     text1 = bible.get_passage('Ecclesiastes', 2, 26)
     # File path parameter should overwrite the default directory, regardless of what it was set to
     bible.default_directory = '../'
     file = '{0}/{1}'.format(self.get_test_directory(), 'Ecclesiastes.yaml')
     text2 = bible.get_passage('Ecclesiastes', 2, 26, file)
     # Translations should be case insensitive under the hood
     self.assertEqual(text1, text2, 'Passages do not match')
示例#3
0
 def test_get_base_passage_with_string_keys(self):
     # Use the JSON file interface, which will only work if the keys are strings and not integers
     bible1 = BaseExtractor(file_reading_function=json_file_interface.read,
                            file_extension='.json',
                            default_directory=self.get_test_directory(),
                            translation=self.get_test_translation(),
                            read_key_as_string=True)
     bible2 = BaseExtractor(file_reading_function=yaml_file_interface.read,
                            file_extension=self.get_test_file_extension(),
                            default_directory=self.get_test_directory(),
                            translation=self.get_test_translation())
     text1 = bible1.get_passage('Ecclesiastes', 1, 2)
     text2 = bible2.get_passage('Ecclesiastes', 1, 2)
     # Result should be the same when extracting the same passage from a file with string keys (with relevant
     # extractor settings) and from a file with integer keys
     self.assertEqual(text1, text2, 'Passages do not match')
示例#4
0
 def test_get_base_passage_with_ascii_punctuation(self):
     bible = BaseExtractor(file_reading_function=yaml_file_interface.read,
                           file_extension=self.get_test_file_extension(),
                           default_directory=self.get_test_directory(),
                           translation=self.get_test_translation(),
                           use_ascii_punctuation=True)
     text = bible.get_passage('Ecclesiastes', 1, 2)
     eccl = '\u00b2 "Vanity of vanities," says the Preacher; "Vanity of vanities, all is vanity."'
     self.assertEqual(eccl, text, 'Passages do not match')
示例#5
0
 def test_get_base_passage(self):
     bible = BaseExtractor(file_reading_function=yaml_file_interface.read,
                           file_extension=self.get_test_file_extension(),
                           default_directory=self.get_test_directory(),
                           translation=self.get_test_translation())
     text = bible.get_passage('Ecclesiastes', 2, 26)
     self.assertEqual(
         '\u00b2\u2076 For to the man who pleases him, God gives wisdom, knowledge, and joy; but '
         'to the sinner he gives travail, to gather and to heap up, that he may give to '
         'him who pleases God. This also is vanity and a chasing after wind.',
         text, 'Passage is incorrect')
示例#6
0
 def test_get_base_passage_kjv(self):
     bible = BaseExtractor(file_reading_function=yaml_file_interface.read,
                           file_extension=self.get_test_file_extension(),
                           translation='KJV',
                           default_directory=self.get_test_directory('KJV'))
     text = bible.get_passage('Ecclesiastes', 2, 26)
     self.assertEqual(
         '\u00b2\u2076 For God giveth to a man that is good in his sight wisdom, and knowledge, '
         'and joy: but to the sinner he giveth travail, to gather and to heap up, that '
         'he may give to him that is good before God. This also is vanity and vexation '
         'of spirit.', text, 'Passage is incorrect')
 def test_get_base_passage_list(self):
     bible = BaseExtractor(file_reading_function=yaml_file_interface.read,
                           file_extension=self.get_test_file_extension(),
                           output_as_list=True,
                           default_directory=self.get_test_directory(),
                           translation=self.get_test_translation())
     text = bible.get_passage('1 John', 1, 8)
     john = [
         '\u2078 If we say that we have no sin, we deceive ourselves, and the truth is not in us. '
     ]
     self.assertEqual(john, text, 'Passage is incorrect')
示例#8
0
 def test_get_base_passage_buffered_first_chapter(self):
     bible = BaseExtractor(file_reading_function=yaml_file_interface.read,
                           file_extension=self.get_test_file_extension(),
                           translation=self.get_test_translation())
     eccl = '\u00b2 I said of laughter, \u201cIt is foolishness;\u201d and of mirth, ' \
            '\u201cWhat does it accomplish?\u201d'
     custom_file = '{0}/{1}'.format(
         self.get_test_directory(),
         'test_get_base_passage_buffered_first_chapter.yaml')
     text = bible.get_passage('Ecclesiastes', 2, 2, file_path=custom_file)
     # Custom file only contains one chapter and one passage, but doesn't start on the first passage or chapter
     self.assertEqual(text, eccl, 'Passages do not match')
示例#9
0
 def test_get_base_passage_buffered_first_passage(self):
     bible = BaseExtractor(file_reading_function=yaml_file_interface.read,
                           file_extension=self.get_test_file_extension(),
                           translation=self.get_test_translation())
     eccl = '\u00b2 \u201cVanity of vanities,\u201d says the Preacher; ' \
            '\u201cVanity of vanities, all is vanity.\u201d'
     custom_file = '{0}/{1}'.format(
         self.get_test_directory(),
         'test_get_base_passage_buffered_first_passage.yaml')
     text = bible.get_passage('Ecclesiastes', 1, 2, file_path=custom_file)
     # Custom file only contains one chapter and one passage, but doesn't start on the first passage
     self.assertEqual(text, eccl, 'Passages do not match')