From: Naoki Kambe Date: Mon, 15 Oct 2012 12:30:48 +0000 (+0900) Subject: [2298] modify test_xsl_handler() X-Git-Tag: trac2487_base~1^2~26^2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa4ca44027d533b691ab8b7605fbe273addc4f95;p=thirdparty%2Fkea.git [2298] modify test_xsl_handler() Remove the obsoleted content and add checks for items in the xsl document which can be also in the xml document. --- diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py index 546f02e34b..7b82b0082d 100644 --- a/src/bin/stats/tests/b10-stats-httpd_test.py +++ b/src/bin/stats/tests/b10-stats-httpd_test.py @@ -941,89 +941,22 @@ class TestStatsHttpd(unittest.TestCase): def test_xsl_handler(self): self.stats_httpd = MyStatsHttpd(get_availaddr()) - self.stats_httpd.get_stats_spec = lambda x,y: \ - { "Dummy" : - [{ - "item_name": "foo", - "item_type": "string", - "item_optional": False, - "item_default": "bar", - "item_description": "foo bar", - "item_title": "Foo" - }, - { - "item_name": "foo2", - "item_type": "list", - "item_optional": False, - "item_default": [ - { - "zonename" : "test1", - "queries.udp" : 1, - "queries.tcp" : 2 - }, - { - "zonename" : "test2", - "queries.udp" : 3, - "queries.tcp" : 4 - } - ], - "item_title": "Foo bar", - "item_description": "Foo bar", - "list_item_spec": { - "item_name": "foo2-1", - "item_type": "map", - "item_optional": False, - "item_default": {}, - "map_item_spec": [ - { - "item_name": "foo2-1-1", - "item_type": "string", - "item_optional": False, - "item_default": "", - "item_title": "Foo2 1 1", - "item_description": "Foo bar" - }, - { - "item_name": "foo2-1-2", - "item_type": "integer", - "item_optional": False, - "item_default": 0, - "item_title": "Foo2 1 2", - "item_description": "Foo bar" - }, - { - "item_name": "foo2-1-3", - "item_type": "integer", - "item_optional": False, - "item_default": 0, - "item_title": "Foo2 1 3", - "item_description": "Foo bar" - } - ] - } - }] - } - xsl_body1 = self.stats_httpd.open_template( - stats_httpd.XSL_TEMPLATE_LOCATION).substitute( - xsl_string='
Module NameModule Item
Dummy
Item NameItem Value
Foo
Foo bar
Item NameItem Value
foo2-1
Item NameItem Value
Foo2 1 1
Foo2 1 2
Foo2 1 3
', - xsd_namespace=stats_httpd.XSD_NAMESPACE) - xsl_body2 = self.stats_httpd.xsl_handler() - self.assertEqual(type(xsl_body1), str) - self.assertEqual(type(xsl_body2), str) - self.assertEqual(xsl_body1, xsl_body2) - self.stats_httpd.get_stats_spec = lambda x,y: \ - { "Dummy" : - [{ - "item_name": "bar", - "item_type": "string", - "item_optional": False, - "item_default": "foo", - "item_description": "bar is foo", - "item_title": "bar" - }] - } - xsl_body2 = self.stats_httpd.xsl_handler() - self.assertNotEqual(xsl_body1, xsl_body2) + xsl_string = self.stats_httpd.xsl_handler() + stats_xsl = xml.etree.ElementTree.fromstring(xsl_string) + nst = '{%s}' % XMLNS_XSL + nsx = '{%s}' % XMLNS_XHTML + self.assertEqual("bind10:statistics", stats_xsl[2].attrib['match']) + stats_xsl = stats_xsl[2].find('%stable' % nsx) + self.assertEqual('item', stats_xsl[1].attrib['select']) + stats_xsl = stats_xsl[1].find('%str' % nsx) + self.assertEqual('@uri', stats_xsl[0].find( + '%selement/%sattribute/%svalue-of' % ((nst,)*3)).attrib['select']) + self.assertEqual('@identifier', stats_xsl[0].find( + '%selement/%svalue-of' % ((nst,)*2)).attrib['select']) + self.assertEqual('@value', stats_xsl[1].find('%sif' % nst).attrib['test']) + self.assertEqual('@value', stats_xsl[1].find('%sif/%svalue-of' % ((nst,)*2)).attrib['select']) + self.assertEqual('@description', stats_xsl[2].find('%sif' % nst).attrib['test']) + self.assertEqual('@description', stats_xsl[2].find('%sif/%svalue-of' % ((nst,)*2)).attrib['select']) def test_for_without_B10_FROM_SOURCE(self): # just lets it go through the code without B10_FROM_SOURCE env