From: Naoki Kambe Date: Tue, 30 Oct 2012 09:14:49 +0000 (+0900) Subject: [2298] add comments in test_item_name_list() X-Git-Tag: trac2487_base~1^2~27^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0b0bf7fe9ac14dbec16310cc84228be1f9cd6d5;p=thirdparty%2Fkea.git [2298] add comments in test_item_name_list() --- diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py index dda66e8244..f588fb7596 100644 --- a/src/bin/stats/tests/b10-stats-httpd_test.py +++ b/src/bin/stats/tests/b10-stats-httpd_test.py @@ -116,8 +116,10 @@ def is_ipv6_enabled(address='::1', port=8001): class TestItemNameList(unittest.TestCase): def test_item_name_list(self): + # for a one-element list self.assertEqual(['a'], stats_httpd.item_name_list({'a':1}, 'a')) + # for a dict under a dict self.assertEqual(['a','a/b'], stats_httpd.item_name_list({'a':{'b':1}}, 'a')) self.assertEqual(['a/b'], @@ -128,18 +130,21 @@ class TestItemNameList(unittest.TestCase): stats_httpd.item_name_list({'a':{'b':{'c':1}}}, 'a/b')) self.assertEqual(['a/b/c'], stats_httpd.item_name_list({'a':{'b':{'c':1}}}, 'a/b/c')) + # for a list under a dict self.assertEqual(['a[2]'], stats_httpd.item_name_list({'a':[1,2,3]}, 'a[2]')) self.assertEqual(['a', 'a[0]', 'a[1]', 'a[2]'], stats_httpd.item_name_list({'a':[1,2,3]}, 'a')) self.assertEqual(['a', 'a[0]', 'a[1]', 'a[2]'], stats_httpd.item_name_list({'a':[1,2,3]}, '')) + # for a list under adict under a dict self.assertEqual(['a', 'a/b', 'a/b[0]', 'a/b[1]', 'a/b[2]'], stats_httpd.item_name_list({'a':{'b':[1,2,3]}}, 'a')) self.assertEqual(['a', 'a/b', 'a/b[0]', 'a/b[1]', 'a/b[2]'], stats_httpd.item_name_list({'a':{'b':[1,2,3]}}, '')) self.assertEqual(['a/b', 'a/b[0]', 'a/b[1]', 'a/b[2]'], stats_httpd.item_name_list({'a':{'b':[1,2,3]}}, 'a/b')) + # for a mixed case of the above self.assertEqual(['a', 'a/b', 'a/b[0]', 'a/b[1]', 'a/b[2]', 'a/c'], stats_httpd.item_name_list( {'a':{'b':[1,2,3], 'c':1}}, 'a')) @@ -149,16 +154,25 @@ class TestItemNameList(unittest.TestCase): self.assertEqual(['a/c'], stats_httpd.item_name_list( {'a':{'b':[1,2,3], 'c':1}}, 'a/c')) + # for specifying a wrong identifier which is not found in + # element self.assertRaises(isc.cc.data.DataNotFoundError, stats_httpd.item_name_list, {'x':1}, 'a') + # for specifying a string in element and an empty string in + # identifier self.assertEqual([], stats_httpd.item_name_list('a', '')) + # for specifying empty strings in element and identifier self.assertEqual([], stats_httpd.item_name_list('', '')) + # for specifying wrong element, which is an non-empty string, + # and an non-empty string in identifier self.assertRaises(isc.cc.data.DataTypeError, stats_httpd.item_name_list, 'a', 'a') + # for specifying None in element and identifier self.assertRaises(isc.cc.data.DataTypeError, stats_httpd.item_name_list, None, None) + # for specifying non-dict in element self.assertRaises(isc.cc.data.DataTypeError, stats_httpd.item_name_list, [1,2,3], 'a') self.assertRaises(isc.cc.data.DataTypeError,