コード例 #1
0
 def test_get_online_chapter_with_excessive_values(self):
     bible = WebExtractor()
     text1 = bible.search('Ecclesiastes 1')
     text2 = bible.get_chapter('Ecclesiastes', -1)
     self.assertEqual(text1, text2, 'Passage is incorrect')
     # This should scale down to the last chapter number of the book
     text1 = bible.search('Ecclesiastes 12')
     text2 = bible.get_chapter('Ecclesiastes', 1000)
     self.assertEqual(text1, text2, 'Passage is incorrect')
コード例 #2
0
    def test_get_online_chapters(self):
        bible = WebExtractor()
        options = self.get_alternative_interface_options()
        for option in options:
            bible.translation = option['translation']
            bible.show_passage_numbers = option['show_passage_numbers']

            text1 = bible.get_chapter('Amos', 8) + '\n' + bible.get_chapter(
                'Amos', 9)
            text2 = bible.get_chapters('Amos', 8, 9)
            # Chapters interface should be the same as requesting the individual chapters with newline separators
            self.assertEqual(text1, text2, 'Passage is incorrect')
コード例 #3
0
 def test_get_online_passage_range_with_intermediate_chapters(self):
     bible = WebExtractor()
     text1 = bible.get_passage('Daniel', 3, 30) + '\n' + \
         bible.get_chapter('Daniel', 4) + '\n' + \
         bible.get_passage('Daniel', 5, 1)
     text2 = bible.get_passage_range('Daniel', 3, 30, 5, 1)
     # A passage range with intermediate chapters should be the same as manually putting all the passages together
     self.assertEqual(text1, text2, 'Passage is incorrect')
コード例 #4
0
    def test_get_online_chapter(self):
        bible = WebExtractor()
        options = self.get_alternative_interface_options()
        for option in options:
            bible.translation = option['translation']
            bible.show_passage_numbers = option['show_passage_numbers']

            text1 = bible.search('Daniel 5')
            text2 = bible.get_chapter('Daniel', 5)
            self.assertEqual(text1, text2, 'Passage is incorrect')
コード例 #5
0
 def test_get_chapter_list_with_ascii_punctuation(self):
     bible = WebExtractor(output_as_list=True,
                          translation=self.get_test_translation(),
                          use_ascii_punctuation=True)
     text = bible.get_chapter('Ecclesiastes', 2)
     static_file = '{0}/test_get_chapter_list_with_ascii_punctuation.txt'.format(
         self.get_test_directory())
     with open(static_file, 'r', encoding='utf-8') as file:
         eccl = file.read()
     # This chapter doesn't have Unicode single quotes, but should have the other translated characters
     self.assertEqual(eccl, ''.join(text), 'Passage is incorrect')
コード例 #6
0
 def test_get_base_chapter_list(self):
     online_bible = WebExtractor(output_as_list=True,
                                 show_passage_numbers=False,
                                 translation=self.get_test_translation())
     bible = BaseExtractor(file_reading_function=yaml_file_interface.read,
                           file_extension=self.get_test_file_extension(),
                           output_as_list=True,
                           show_passage_numbers=False,
                           default_directory=self.get_test_directory(),
                           translation=self.get_test_translation())
     text = bible.get_chapter('Ecclesiastes', 11)
     eccl = online_bible.get_chapter('Ecclesiastes', 11)
     # Results should be identical between the web and base extractor
     # Ignoring passage numbers, as the web extractor omits this for the first passage of each chapter
     self.assertEqual(eccl, text, 'Passage is incorrect')
コード例 #7
0
 def test_get_chapter_list(self):
     bible = WebExtractor(output_as_list=True)
     text = bible.get_chapter('Ecclesiastes', 11)
     eccl11 = [
         'Ship your grain across the sea;\n'
         '    after many days you may receive a return.\n',
         '\u00b2 Invest in seven ventures, yes, in eight;\n'
         '    you do not know what disaster may come upon the land. \n',
         '\u00b3 If clouds are full of water,\n'
         '    they pour rain on the earth.\n'
         'Whether a tree falls to the south or to the north,\n'
         '    in the place where it falls, there it will lie.\n',
         '\u2074 Whoever watches the wind will not plant;\n'
         '    whoever looks at the clouds will not reap. \n',
         '\u2075 As you do not know the path of the wind,\n'
         '    or how the body is formed in a mother\u2019s womb,\n'
         'so you cannot understand the work of God,\n'
         '    the Maker of all things. \n',
         '\u2076 Sow your seed in the morning,\n'
         '    and at evening let your hands not be idle,\n'
         'for you do not know which will succeed,\n'
         '    whether this or that,\n'
         '    or whether both will do equally well. \n',
         '\u2077 Light is sweet,\n'
         '    and it pleases the eyes to see the sun.\n',
         '\u2078 However many years anyone may live,\n'
         '    let them enjoy them all.\nBut let them remember the days of darkness,\n'
         '    for there will be many.\n'
         '    Everything to come is meaningless. \n',
         '\u2079 You who are young, be happy while you are young,\n'
         '    and let your heart give you joy in the days of your youth.\n'
         'Follow the ways of your heart\n'
         '    and whatever your eyes see,\n'
         'but know that for all these things\n'
         '    God will bring you into judgment.\n',
         '\u00b9\u2070 So then, banish anxiety from your heart\n'
         '    and cast off the troubles of your body,\n'
         '    for youth and vigor are meaningless.'
     ]
     self.assertEqual(eccl11, text, 'Passage is incorrect')
コード例 #8
0
 def test_get_chapters_list(self):
     bible = WebExtractor(output_as_list=True)
     text = bible.get_chapters('1 John', 1, 2)
     john = bible.get_chapter('1 John', 1) + bible.get_chapter('1 John', 2)
     # Getting multiple sequential chapters should be the same as appending multiple chapters manually
     self.assertEqual(john, text, 'Passage is incorrect')