-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
82 lines (57 loc) · 2.26 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import unittest
from lxml import etree
from src import *
class TestGenerateHTML(unittest.TestCase):
# Show long diffs
maxDiff = None
def test_orig(self):
tei_root = parse_xml_file('./tests/input.xml')
xslt_path = "./xslt/test.xslt"
flex_path = "./tests/test_flex_export.json"
html_root = generate_html(
tei_root,
xslt_path=xslt_path,
flex_path=flex_path,
text="levanto-arte",
spellchoice=SPELLCHOICE_ORIG,
abbrchoice=ABBRCHOICE_ABBR
)
generated_html_string = etree.tostring(html_root, method="xml", encoding="unicode")
with open("./tests/output.html", "r", encoding="utf-8") as f:
expected_html_string = f.read()
self.assertEqual(generated_html_string, expected_html_string)
def test_reg(self):
tei_root = parse_xml_file('./tests/input.xml')
xslt_path = "./xslt/test.xslt"
flex_path = "./tests/test_flex_export.json"
html_root = generate_html(
tei_root,
xslt_path=xslt_path,
flex_path=flex_path,
text="levanto-arte",
spellchoice=SPELLCHOICE_SPANISH,
abbrchoice=ABBRCHOICE_ABBR
)
generated_html_string = etree.tostring(html_root, method="xml", encoding="unicode")
with open("./tests/output_reg.html", "r", encoding="utf-8") as f:
expected_html_string = f.read()
self.assertEqual(generated_html_string, expected_html_string)
class TestGenerateOutline(unittest.TestCase):
# Show long diffs
maxDiff = None
def test_outline(self):
text = "levanto-arte"
path = "./tests/input.xml"
with open(path, "r", encoding="utf-8") as f:
data = f.read()
target = OutlineBuilder(text=text)
parser = ET.XMLParser(target=target)
parser.feed(data)
root = target.close()
generated_html_string = ET.tostring(root, encoding="unicode")
with open("./tests/output_outline.html", "r", encoding="utf-8") as g:
expected_html_string = g.read()
self.assertEqual(generated_html_string, expected_html_string)
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
unittest.main()