Page MenuHomec4science

test_process_footnotes.py
No OneTemporary

File Metadata

Created
Sat, May 4, 01:40

test_process_footnotes.py

import unittest
from os import sep, path, remove
from os.path import isdir, isfile, dirname
import shutil
import sys
import lxml.etree as ET
import warnings
import sys
sys.path.append('svgscripts')
from datatypes.footnotes import extract_footnotes
from datatypes.page import Page
import process_footnotes
from process_footnotes import categorize_footnotes, main
class TestExtractFootnotes(unittest.TestCase):
def setUp(self):
process_footnotes.UNITTESTING = True
DATADIR = path.dirname(__file__) + sep + 'test_data'
self.test_footnote = DATADIR + sep + 'W_I_8_neu_125-01.svg'
self.test_footnote_verso = DATADIR + sep + 'N_VII_1_xp5_4_page5.svg'
self.test_footnote_recto = DATADIR + sep + 'N_VII_1_xp5_4_page6.svg'
self.test_footnote_multi = DATADIR + sep + 'N_VII_1_xp5_4_page13.svg'
self.test_footnote_multi_xml = DATADIR + sep + 'N_VII_1_page013.xml'
self.test_categorize_footnote = DATADIR + sep + 'N_VII_1_page006.xml'
def test_categorize_footnotes(self):
page = Page(self.test_categorize_footnote)
footnotes = extract_footnotes(page, svg_file=self.test_footnote_recto)
categorize_footnotes(page, footnotes)
words_with_comments = [ word for word in page.words if word.editor_comment is not None ]
self.assertEqual(len(words_with_comments), 4)
lines_with_comments = [ line for line in page.lines if len(line.editor_comments) > 0 ]
self.assertEqual(len(lines_with_comments), 1)
page = Page('xml/W_II_1_page141.xml')
footnotes = extract_footnotes(page)
categorize_footnotes(page, footnotes, debug=True)
words_with_comments = [ word for word in page.words if word.editor_comment is not None ]
#self.assertEqual(len(words_with_comments), 9)
def test_main(self):
self.assertEqual(main(['xml/N_VII_1_page005.xml']), 0)
if __name__ == "__main__":
unittest.main()

Event Timeline