Commit b1cb4c4a authored by Naoki Kambe's avatar Naoki Kambe
Browse files

[trac547] added more tests into test_open_template

 - checking the type of object returned from open_template method
 - checking the string values replaced by the substitute method in string.Template
parent 521c140d
...@@ -338,9 +338,32 @@ class TestStatsHttpd(unittest.TestCase): ...@@ -338,9 +338,32 @@ class TestStatsHttpd(unittest.TestCase):
def test_open_template(self): def test_open_template(self):
# successful conditions # successful conditions
self.stats_httpd.open_template(stats_httpd.XML_TEMPLATE_LOCATION) tmpl = self.stats_httpd.open_template(stats_httpd.XML_TEMPLATE_LOCATION)
self.stats_httpd.open_template(stats_httpd.XSD_TEMPLATE_LOCATION) self.assertTrue(isinstance(tmpl, string.Template))
self.stats_httpd.open_template(stats_httpd.XSL_TEMPLATE_LOCATION) opts = dict(
xml_string="<dummy></dummy>",
xsd_namespace="http://host/path/to/",
xsd_url_path="/path/to/",
xsl_url_path="/path/to/")
lines = tmpl.substitute(opts)
for n in opts:
self.assertTrue(lines.find(opts[n])>0)
tmpl = self.stats_httpd.open_template(stats_httpd.XSD_TEMPLATE_LOCATION)
self.assertTrue(isinstance(tmpl, string.Template))
opts = dict(
xsd_string="<dummy></dummy>",
xsd_namespace="http://host/path/to/")
lines = tmpl.substitute(opts)
for n in opts:
self.assertTrue(lines.find(opts[n])>0)
tmpl = self.stats_httpd.open_template(stats_httpd.XSL_TEMPLATE_LOCATION)
self.assertTrue(isinstance(tmpl, string.Template))
opts = dict(
xsl_string="<dummy></dummy>",
xsd_namespace="http://host/path/to/")
lines = tmpl.substitute(opts)
for n in opts:
self.assertTrue(lines.find(opts[n])>0)
# unsuccessful condition # unsuccessful condition
self.assertRaises( self.assertRaises(
IOError, IOError,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment