def test_get_base_book_ascii_punctuation_count(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=False) text1 = bible.get_book('Ecclesiastes') bible.use_ascii_punctuation = True text2 = bible.get_book('Ecclesiastes') # Check that the punctuation conversion is a 1:1 translation self.assertEqual( text1.count('\u201c') + text1.count('\u201d'), text2.count('"'), 'Double quotes are unequal') self.assertEqual( text1.count('\u2018') + text1.count('\u2019'), text2.count("'"), 'Single quotes are unequal') self.assertEqual(text1.count('\u2014'), text2.count('-'), 'Dashes are unequal')
def test_get_base_book(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_book('Philemon') static_file = '{0}/test_get_base_book.txt'.format( self.get_test_directory()) with open(static_file, 'r', encoding='utf-8') as file: phil = file.read() self.assertEqual(phil, text, 'Passage is incorrect')
def test_get_base_book_list(self): online_bible = WebExtractor(output_as_list=True, 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, default_directory=self.get_test_directory(), translation=self.get_test_translation()) text = bible.get_book('Philemon') eccl = online_bible.get_book('Philemon') # Results should be identical between the web and base extractor self.assertEqual(eccl, text, 'Passage is incorrect')
def test_get_base_book_list_with_ascii_punctuation(self): online_bible = WebExtractor(output_as_list=True, translation=self.get_test_translation(), show_passage_numbers=False, use_ascii_punctuation=True) 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(), show_passage_numbers=False, use_ascii_punctuation=True) text = bible.get_book('Ecclesiastes') eccl = online_bible.get_book('Ecclesiastes') # Results should be identical between the web and base extractor self.assertEqual(eccl, text, 'Passage is incorrect')