# examining the third value from the array result of
# 'show_processes' of Init
seq = self.cc_session.group_sendmsg(
- isc.config.ccsession.create_command("show_processes"),
- 'Init')
+ isc.config.ccsession.create_command("show_processes"), 'Init')
(answer, env) = self.cc_session.group_recvmsg(False, seq)
modules = []
if answer:
# merge recursively old value and new
# value each other
_data[owner][mid] = \
- merge_oldnew(_data[owner][mid],
- {_key: _val})
+ merge_oldnew(_data[owner][mid], {_key: _val})
continue
# the key string might be a "xx/yy/zz[0]"
# type. try it.
if errors: errors.pop()
# try updata and check validation in adavance
__data = _data.copy()
- if owner not in _data:
+ if owner not in __data:
__data[owner] = {}
- if mid not in _data[owner]:
+ if mid not in __data[owner]:
__data[owner][mid] = {}
# use the isc.cc.data.set method
try:
False, __data[owner][mid], errors):
_data = __data
except Exception as e:
- errors.append(
- "%s: %s" % (e.__class__.__name__, e))
+ errors.append("%s: %s" % (e.__class__.__name__, e))
except KeyError:
- errors.append("unknown module name: " + str(owner))
+ errors.append("unknown module name: " + owner)
if not errors:
self.statistics_data_bymid = _data
# values are not replaced.
self.statistics_data[m] = merge_oldnew(
self.statistics_data[m],
- _accum_bymodule(
- self.statistics_data_bymid[m]))
+ _accum_bymodule(self.statistics_data_bymid[m]))
if errors: return errors
def test_update_statistics_data_pt2(self):
"""test for named_set-type statistics"""
- self.stats = stats.Stats()
- self.stats.do_polling()
- _test_exp1 = {
- 'test10.example': {
- 'queries.tcp': 5,
- 'queries.udp': 4
- }
- }
- _test_exp2 = {
- 'test20.example': {
- 'queries.tcp': 3,
- 'queries.udp': 2
- }
- }
+ self.stats = SimpleStats()
+ _test_exp1 = \
+ { 'test10.example': { 'queries.tcp': 5, 'queries.udp': 4 } }
+ _test_exp2 = \
+ { 'test20.example': { 'queries.tcp': 3, 'queries.udp': 2 } }
_test_exp3 = {}
- _test_exp4 = {
- 'test20.example': {
- 'queries.udp': 4
- }
- }
- _test_exp5_1 = {
- 'test10.example': {
- 'queries.udp': 5432
- }
- }
+ _test_exp4 = { 'test20.example': { 'queries.udp': 4 } }
+ _test_exp5_1 = { 'test10.example': { 'queries.udp': 5432 } }
_test_exp5_2 ={
'nds_queries.perzone/test10.example/queries.udp':
- isc.cc.data.find(_test_exp5_1,
- 'test10.example/queries.udp')
- }
- _test_exp6 = {
- 'foo/bar': 'brabra'
- }
- _test_exp7 = {
- 'foo[100]': 'bar'
+ isc.cc.data.find(_test_exp5_1, 'test10.example/queries.udp')
}
+ _test_exp6 = { 'foo/bar': 'brabra' }
+ _test_exp7 = { 'foo[100]': 'bar' }
# Success cases
self.assertIsNone(self.stats.update_statistics_data(
'Auth', 'foo1', {'nds_queries.perzone': _test_exp1}))
['foo1']['nds_queries.perzone'],\
dict(_test_exp1,**_test_exp2))
self.assertIsNone(self.stats.update_statistics_data(
- 'Auth', 'foo1', {'nds_queries.perzone': dict(_test_exp1,**_test_exp2)}))
+ 'Auth', 'foo1', {'nds_queries.perzone':
+ dict(_test_exp1, **_test_exp2)}))
self.assertEqual(self.stats.statistics_data_bymid['Auth']\
['foo1']['nds_queries.perzone'],
- dict(_test_exp1,**_test_exp2))
+ dict(_test_exp1, **_test_exp2))
# differential update
self.assertIsNone(self.stats.update_statistics_data(
- 'Auth', 'foo1', {'nds_queries.perzone': dict(_test_exp3,**_test_exp4)}))
+ 'Auth', 'foo1', {'nds_queries.perzone':
+ dict(_test_exp3, **_test_exp4)}))
_new_val = dict(_test_exp1,
**stats.merge_oldnew(_test_exp2,_test_exp4))
self.assertEqual(self.stats.statistics_data_bymid['Auth']\
_test_exp5_1)
# Error cases
self.assertEqual(self.stats.update_statistics_data(
- 'Auth', 'foo1', {'nds_queries.perzone': None}), ['None should be a map'])
+ 'Auth', 'foo1', {'nds_queries.perzone': None}),
+ ['None should be a map'])
self.assertEqual(self.stats.statistics_data_bymid['Auth']\
['foo1']['nds_queries.perzone'],\
_new_val)