Skip to content

Commit d6bc508

Browse files
committed
[test/xml_writer] Test style content
1 parent a11dd14 commit d6bc508

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

test/test_xml_writer.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,28 @@ def test_write_default(self):
3838
doc = odml.load(self.outfile)
3939
self.assertEqual(doc, self.doc)
4040

41+
# test style content in saved file
42+
with open(self.outfile) as test_file:
43+
content = test_file.read()
44+
45+
self.assertIn(XML_HEADER, content)
46+
self.assertIn(EXTERNAL_STYLE_HEADER, content)
47+
4148
def test_write_style_default(self):
4249
self.writer.write_file(self.outfile, local_style=True)
4350

4451
# make sure the file can be read again without errors
4552
doc = odml.load(self.outfile)
4653
self.assertEqual(doc, self.doc)
4754

55+
# test style content in saved file
56+
with open(self.outfile) as test_file:
57+
content = test_file.read()
58+
59+
self.assertIn(XML_HEADER, content)
60+
self.assertIn(INFILE_STYLE_HEADER, content)
61+
self.assertIn(INFILE_STYLE_TEMPLATE, content)
62+
4863
def test_write_style_custom(self):
4964
# template stub just to see if its written properly; will not render anything
5065
cust_tmpl = "<xsl:template></xsl:template>"
@@ -55,9 +70,27 @@ def test_write_style_custom(self):
5570
doc = odml.load(self.outfile)
5671
self.assertEqual(doc, self.doc)
5772

58-
# test second possible way to save
73+
# test style content in saved file
74+
with open(self.outfile) as test_file:
75+
content = test_file.read()
76+
77+
self.assertIn(XML_HEADER, content)
78+
self.assertIn(INFILE_STYLE_HEADER, content)
79+
self.assertNotIn(INFILE_STYLE_TEMPLATE, content)
80+
self.assertIn(cust_tmpl, content)
81+
82+
# --- test second possible way to save
5983
self.writer.write_file(self.outfile, local_style=False, custom_template=cust_tmpl)
6084

6185
# make sure the file can be read again without errors
6286
doc = odml.load(self.outfile)
6387
self.assertEqual(doc, self.doc)
88+
89+
# test style content in saved file
90+
with open(self.outfile) as test_file:
91+
content = test_file.read()
92+
93+
self.assertIn(XML_HEADER, content)
94+
self.assertIn(INFILE_STYLE_HEADER, content)
95+
self.assertNotIn(INFILE_STYLE_TEMPLATE, content)
96+
self.assertIn(cust_tmpl, content)

0 commit comments

Comments
 (0)