00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 import sys
00040 import unittest
00041 try:
00042 from xmlrpc.client import DateTime
00043 except ImportError:
00044 from xmlrpclib import DateTime
00045 import math
00046 import datetime
00047 import random
00048 import traceback
00049
00050 import rostest
00051 from roslib.names import make_global_ns, ns_join
00052
00053 from rosclient import TestRosClient
00054
00055 HAS_PARAM = True
00056
00057
00058
00059
00060 class ParamServerTestCase(TestRosClient):
00061
00062 def _setParam(self, ctx, myState, testVals, master):
00063 ctx = make_global_ns(ctx)
00064 for type, vals in testVals:
00065 try:
00066 callerId = ns_join(ctx, "node")
00067 count = 0
00068 for val in vals:
00069 key = "%s-%s"%(type,count)
00070
00071 master.setParam(callerId, key, val)
00072 self.assert_(self.apiSuccess(master.hasParam(callerId, key)))
00073 trueKey = ns_join(ctx, key)
00074 myState[trueKey] = val
00075 count += 1
00076 except Exception:
00077 assert "getParam failed on type[%s], val[%s]"%(type,val)
00078
00079
00080 def _checkParamState(self, myState):
00081 master = self.master
00082 callerId = 'master'
00083 for (k, v) in myState.items():
00084 assert self.apiSuccess(master.hasParam(callerId, k))
00085
00086 try:
00087 v2 = self.apiSuccess(master.getParam(callerId, k))
00088 except:
00089 raise Exception("Exception raised while calling master.getParam(%s,%s): %s"%(callerId, k, traceback.format_exc()))
00090 if isinstance(v2, DateTime):
00091 self.assertEquals(DateTime(v), v2, "[%s]: %s != %s, %s"%(k, v, v2, v2.__class__))
00092 elif type(v2) == float:
00093 self.assertAlmostEqual(v, v2, 3, "[%s]: %s != %s, %s"%(k, v, v2, v2.__class__))
00094 else:
00095 self.assertEquals(v, v2)
00096 paramNames = myState.keys()
00097 remoteParamNames = self.apiSuccess(master.getParamNames(callerId))
00098
00099 remoteParamNames = [p for p in remoteParamNames if not p in ['/run_id', '/rosdistro', '/rosversion']]
00100 remoteParamNames = [p for p in remoteParamNames if not p.startswith('/roslaunch/')]
00101
00102 assert not set(paramNames) ^ set(remoteParamNames), "parameter server keys do not match local: %s"%(set(paramNames)^set(remoteParamNames))
00103
00104
00105
00106 def _testHasParam(self):
00107 master = self.master
00108 caller_id = '/node'
00109 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/new_param')))
00110 self.apiSuccess(master.setParam(caller_id, '/new_param', 1))
00111 self.assert_(self.apiSuccess(master.hasParam(caller_id, '/new_param')))
00112
00113 self.assert_(self.apiSuccess(master.hasParam(caller_id, 'new_param')))
00114
00115
00116 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/sub/sub2/new_param2')))
00117
00118 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/sub/sub2/')))
00119 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/sub/sub2')))
00120 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/sub/')))
00121 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/sub')))
00122 self.apiSuccess(master.setParam(caller_id, '/sub/sub2/new_param2', 1))
00123 self.assert_(self.apiSuccess(master.hasParam(caller_id, '/sub/sub2/new_param2')))
00124
00125 self.assert_(self.apiSuccess(master.hasParam(caller_id, '/sub/sub2/')))
00126 self.assert_(self.apiSuccess(master.hasParam(caller_id, '/sub/sub2')))
00127 self.assert_(self.apiSuccess(master.hasParam(caller_id, '/sub/')))
00128 self.assert_(self.apiSuccess(master.hasParam(caller_id, '/sub')))
00129
00130 self.assert_(self.apiSuccess(master.hasParam(caller_id, 'sub/sub2/new_param2')))
00131 self.assert_(self.apiSuccess(master.hasParam('/sub/node', 'sub2/new_param2')))
00132 self.assert_(self.apiSuccess(master.hasParam('/sub/sub2/node', 'new_param2')))
00133 self.assert_(self.apiSuccess(master.hasParam('/sub/node', 'sub2')))
00134 self.assert_(self.apiSuccess(master.hasParam('/node', 'sub')))
00135
00136
00137 def _testSearchParam(self):
00138 master = self.master
00139 caller_id = '/node'
00140
00141
00142 val1 = { 'level1_p1': random.randint(0, 10000),
00143 'level1_p2' : { 'level2_p2': random.randint(0, 10000) }}
00144 val2 = { 'level1_p1': random.randint(0, 10000),
00145 'level1_p2' : { 'level2_p2': random.randint(0, 10000) }}
00146 val3 = { 'level1_p1': random.randint(0, 10000),
00147 'level1_p2' : { 'level2_p2': random.randint(0, 10000) }}
00148 val4 = { 'level1_p1': random.randint(0, 10000),
00149 'level1_p2' : { 'level2_p2': random.randint(0, 10000) }}
00150 full_dict = {}
00151
00152
00153 caller_id = '/root'
00154 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/param')))
00155 self.apiSuccess(master.setParam(caller_id, '/param', val1))
00156
00157 self.assertEquals('/param', self.apiSuccess(master.searchParam(caller_id, 'param')))
00158
00159 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/level1/param')))
00160 self.apiSuccess(master.setParam(caller_id, '/level1/param', val2))
00161 self.assertEquals(val2, self.apiSuccess(master.getParam(caller_id, '/level1/param')))
00162
00163 self.assertEquals('/param',
00164 self.apiSuccess(master.searchParam(caller_id, 'param')))
00165 self.assertEquals('/level1/param',
00166 self.apiSuccess(master.searchParam('/level1/node', 'param')))
00167
00168 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/level1/level2/param')))
00169 self.apiSuccess(master.setParam(caller_id, '/level1/level2/param', val3))
00170
00171 self.assertEquals('/param',
00172 self.apiSuccess(master.searchParam(caller_id, 'param')))
00173 self.assertEquals('/level1/param',
00174 self.apiSuccess(master.searchParam('/level1/node', 'param')))
00175 self.assertEquals('/level1/level2/param',
00176 self.apiSuccess(master.searchParam('/level1/level2/node', 'param')))
00177 self.assertEquals('/level1/level2/param',
00178 self.apiSuccess(master.searchParam('/level1/level2/level3/level4/node', 'param')))
00179
00180 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/level1/level2/level3/level4/param')))
00181 self.apiSuccess(master.setParam(caller_id, '/level1/level2/level3/level4/param', val4))
00182
00183 self.assertEquals('/param',
00184 self.apiSuccess(master.searchParam(caller_id, 'param')))
00185 self.assertEquals('/level1/param',
00186 self.apiSuccess(master.searchParam('/level1/node', 'param')))
00187 self.assertEquals('/level1/level2/param',
00188 self.apiSuccess(master.searchParam('/level1/level2/node', 'param')))
00189 self.assertEquals('/level1/level2/param',
00190 self.apiSuccess(master.searchParam('/level1/level2/level3/node', 'param')))
00191 self.assertEquals('/level1/level2/level3/level4/param',
00192 self.apiSuccess(master.searchParam('/level1/level2/level3/level4/node', 'param')))
00193
00194
00195 self.assertEquals('/param', self.apiSuccess(master.searchParam('/not/level1/level2/level3/level4/node', 'param')))
00196
00197 tests = [('/param', '/not/level1/level2/level3/level4/node'),
00198 ('/level1/param', '/level1/node'),
00199 ('/level1/param', '/level1/notlevel2/notlevel3/node'),
00200 ('/level1/level2/param', '/level1/level2/node'),
00201 ('/level1/level2/param', '/level1/level2/level3/node'),
00202 ('/level1/level2/param', '/level1/level2/notlevel3/notlevel3/node'),
00203 ('/level1/level2/level3/level4/param', '/level1/level2/level3/level4/node'),
00204 ('/level1/level2/level3/level4/param', '/level1/level2/level3/level4/l5/l6/node'),
00205 ]
00206 for pbase, caller_id in tests:
00207 self.assertEquals(pbase + '/level1_p1',
00208 self.apiSuccess(master.searchParam(caller_id, 'param/level1_p1')))
00209 key = pbase+'/level1_p2/level2_p2'
00210 self.assertEquals(key,
00211 self.apiSuccess(master.searchParam(caller_id, 'param/level1_p2/level2_p2')))
00212
00213
00214 if self.apiSuccess(master.hasParam(caller_id, key)):
00215 self.apiSuccess(master.deleteParam(caller_id, key))
00216 self.assertEquals(key,
00217 self.apiSuccess(master.searchParam(caller_id, 'param/level1_p2/level2_p2')))
00218
00219 self.assertEquals(pbase + '/non_existent',
00220 self.apiSuccess(master.searchParam(caller_id, 'param/non_existent')))
00221 self.assertEquals(pbase + '/level1_p2/non_existent',
00222 self.apiSuccess(master.searchParam(caller_id, 'param/level1_p2/non_existent')))
00223
00224
00225
00226 def _filterDict(self, d):
00227 for k in ['run_id', 'roslaunch', 'rosversion', 'rosdistro']:
00228 if k in d:
00229 del d[k]
00230 return d
00231
00232
00233 def _testGetParam(self):
00234 master = self.master
00235 caller_id = '/node'
00236 val = random.randint(0, 10000)
00237
00238 full_dict = {}
00239
00240
00241 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/new_param')))
00242 self.apiSuccess(master.setParam(caller_id, '/new_param', val))
00243 full_dict['new_param'] = val
00244 self.assertEquals(val, self.apiSuccess(master.getParam(caller_id, '/new_param')))
00245
00246 self.assertEquals(val, self.apiSuccess(master.getParam(caller_id, 'new_param')))
00247
00248 ps_full_dict = self.apiSuccess(master.getParam(caller_id, '/'))
00249 self._filterDict(ps_full_dict)
00250
00251 self.assertEquals(full_dict, ps_full_dict)
00252
00253
00254 val = random.randint(0, 10000)
00255 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/sub/sub2/new_param2')))
00256 self.apiSuccess(master.setParam(caller_id, '/sub/sub2/new_param2', val))
00257 full_dict['sub'] = {'sub2': { 'new_param2': val }}
00258 self.assertEquals(val, self.apiSuccess(master.getParam(caller_id, '/sub/sub2/new_param2')))
00259
00260 self.assertEquals(val, self.apiSuccess(master.getParam(caller_id, 'sub/sub2/new_param2')))
00261 self.assertEquals(val, self.apiSuccess(master.getParam('/sub/node', 'sub2/new_param2')))
00262 self.assertEquals(val, self.apiSuccess(master.getParam('/sub/sub2/node', 'new_param2')))
00263
00264 self.assertEquals(val, self.apiSuccess(master.getParam('/foo/bar/baz/blah/node', '/sub/sub2/new_param2')))
00265
00266 ps_full_dict = self.apiSuccess(master.getParam(caller_id, '/'))
00267 self._filterDict(ps_full_dict)
00268 self.assertEquals(full_dict, ps_full_dict)
00269
00270
00271
00272 val1 = random.randint(0, 10000)
00273 val2 = random.randint(0, 10000)
00274 val3 = random.randint(0, 10000)
00275
00276 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/gains/P')))
00277 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/gains/I')))
00278 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/gains/D')))
00279 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/gains')))
00280
00281 self.apiSuccess(master.setParam(caller_id, '/gains/P', val1))
00282 self.apiSuccess(master.setParam(caller_id, '/gains/I', val2))
00283 self.apiSuccess(master.setParam(caller_id, '/gains/D', val3))
00284
00285 pid = {'P': val1, 'I': val2, 'D': val3}
00286 full_dict['gains'] = pid
00287 self.assertEquals(pid,
00288 self.apiSuccess(master.getParam(caller_id, '/gains')))
00289 self.assertEquals(pid,
00290 self.apiSuccess(master.getParam(caller_id, '/gains/')))
00291 ps_full_dict = self.apiSuccess(master.getParam(caller_id, '/'))
00292 self._filterDict(ps_full_dict)
00293 self.assertEquals(full_dict, ps_full_dict)
00294
00295 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/ns/gains/P')))
00296 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/ns/gains/I')))
00297 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/ns/gains/D')))
00298 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/ns/gains')))
00299
00300 self.apiSuccess(master.setParam(caller_id, '/ns/gains/P', val1))
00301 self.apiSuccess(master.setParam(caller_id, '/ns/gains/I', val2))
00302 self.apiSuccess(master.setParam(caller_id, '/ns/gains/D', val3))
00303 full_dict['ns'] = {'gains': pid}
00304
00305 self.assertEquals(pid,
00306 self.apiSuccess(master.getParam(caller_id, '/ns/gains')))
00307 self.assertEquals({'gains': pid},
00308 self.apiSuccess(master.getParam(caller_id, '/ns/')))
00309 self.assertEquals({'gains': pid},
00310 self.apiSuccess(master.getParam(caller_id, '/ns')))
00311 ps_full_dict = self.apiSuccess(master.getParam(caller_id, '/'))
00312 self._filterDict(ps_full_dict)
00313 self.assertEquals(full_dict, ps_full_dict)
00314
00315
00316
00317 def _testSetParam(self):
00318 master = self.master
00319 caller_id = '/node'
00320 val = random.randint(0, 10000)
00321
00322
00323 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/new_param')))
00324 self.apiSuccess(master.setParam(caller_id, '/new_param', val))
00325 self.assertEquals(val, self.apiSuccess(master.getParam(caller_id, '/new_param')))
00326
00327 self.assertEquals(val, self.apiSuccess(master.getParam(caller_id, 'new_param')))
00328
00329
00330 vals = ['a', {'a': 'b'}, 1, 1., 'foo', {'c': 'd'}, 4]
00331 for v in vals:
00332 self.apiSuccess(master.setParam(caller_id, '/multi/multi_param', v))
00333 self.assertEquals(v, self.apiSuccess(master.getParam(caller_id, 'multi/multi_param')))
00334
00335
00336 val = random.randint(0, 10000)
00337 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/sub/sub2/new_param2')))
00338 self.apiSuccess(master.setParam(caller_id, '/sub/sub2/new_param2', val))
00339 self.assertEquals(val, self.apiSuccess(master.getParam(caller_id, '/sub/sub2/new_param2')))
00340
00341 self.assertEquals(val, self.apiSuccess(master.getParam(caller_id, 'sub/sub2/new_param2')))
00342 self.assertEquals(val, self.apiSuccess(master.getParam('/sub/node', 'sub2/new_param2')))
00343 self.assertEquals(val, self.apiSuccess(master.getParam('/sub/sub2/node', 'new_param2')))
00344
00345
00346 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/gains/P')))
00347 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/gains/I')))
00348 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/gains/D')))
00349 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/gains')))
00350
00351 pid = {'P': random.randint(0, 10000), 'I': random.randint(0, 10000), 'D': random.randint(0, 10000)}
00352 self.apiSuccess(master.setParam(caller_id, '/gains', pid))
00353 self.assertEquals(pid, self.apiSuccess(master.getParam(caller_id, '/gains')))
00354 self.assertEquals(pid['P'], self.apiSuccess(master.getParam(caller_id, '/gains/P')))
00355 self.assertEquals(pid['I'], self.apiSuccess(master.getParam(caller_id, '/gains/I')))
00356 self.assertEquals(pid['D'], self.apiSuccess(master.getParam(caller_id, '/gains/D')))
00357
00358 subns = {'gains1': pid, 'gains2': pid}
00359 self.apiSuccess(master.setParam(caller_id, '/ns', subns))
00360 self.assertEquals(pid['P'], self.apiSuccess(master.getParam(caller_id, '/ns/gains1/P')))
00361 self.assertEquals(pid['I'], self.apiSuccess(master.getParam(caller_id, '/ns/gains1/I')))
00362 self.assertEquals(pid['D'], self.apiSuccess(master.getParam(caller_id, '/ns/gains1/D')))
00363 self.assertEquals(pid, self.apiSuccess(master.getParam(caller_id, '/ns/gains1')))
00364 self.assertEquals(pid, self.apiSuccess(master.getParam(caller_id, '/ns/gains2')))
00365 self.assertEquals(subns, self.apiSuccess(master.getParam(caller_id, '/ns/')))
00366
00367
00368 self.apiSuccess(master.setParam(caller_id, '/ns', {}))
00369
00370 self.assert_(self.apiSuccess(master.hasParam(caller_id, '/ns/')))
00371
00372 self.assertEquals({}, self.apiSuccess(master.getParam(caller_id, '/ns/')))
00373
00374 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/ns/gains1')))
00375 self.failIf(self.apiSuccess(master.hasParam(caller_id, '/ns/gains1/P')))
00376
00377
00378
00379 def _testParamValues(self):
00380 try:
00381 from xmlrpc.client import Binary
00382 except ImportError:
00383 from xmlrpclib import Binary
00384 str_of_bytes = ''.join([chr(n) for n in range(0, 255)])
00385 if not isinstance(str_of_bytes, bytes):
00386 str_of_bytes = bytes(range(255))
00387 testVals = [
00388 ['int', [0, 1024, 2147483647, -2147483647]],
00389 ['boolean', [True, False]],
00390
00391
00392 ['unicode-string', [u'', u'hello', b'Andr\302\202'.decode('utf-8'), b'\377\376A\000n\000d\000r\000\202\000'.decode('utf-16')]],
00393 ['string-easy-ascii', [chr(n) for n in range(32, 128)]],
00394
00395
00396
00397
00398 ['string', ['', 'x', 'hello-there', 'new\nline', 'tab\t']],
00399 ['double', [0.0, math.pi, -math.pi, 3.4028235e+38, -3.4028235e+38]],
00400
00401 ['datetime', [datetime.datetime(2005, 12, 6, 12, 13, 14), datetime.datetime(1492, 12, 6, 12, 13, 14)]],
00402 ['base64', [Binary(b''), Binary(b'\0'), Binary(str_of_bytes)]],
00403 ['array', [[], [1, 2, 3], ['a', 'b', 'c'], [0.0, 0.1, 0.2, 2.0, 2.1, -4.0],
00404 [1, 'a', True], [[1, 2, 3], ['a', 'b', 'c'], [1.0, 2.1, 3.2]]]
00405 ],
00406 ]
00407 master = self.master
00408
00409 print("Putting parameters onto the server")
00410
00411 contexts = ['', 'scope1', 'scope/sub1/sub2']
00412 myState = {}
00413 failures = []
00414 for ctx in contexts:
00415 self._setParam(ctx, myState, testVals, master)
00416 self._checkParamState(myState)
00417
00418 print("Deleting all of our parameters")
00419
00420 ctx = ''
00421 count = 0
00422 for key in list(myState.keys()):
00423 count += 1
00424 print("deleting [%s], [%s]" % (ctx, key))
00425 self.apiSuccess(master.deleteParam(ctx, key))
00426 del myState[key]
00427
00428 if count % 50 == 0:
00429 self._checkParamState(myState)
00430 self._checkParamState(myState)
00431
00432 def _testEncapsulation(self):
00433 """testEncapsulation: test encapsulation: setting same parameter at different levels"""
00434 master = self.master
00435 myState = {}
00436 self._checkParamState(myState)
00437
00438 testContexts = ['', 'en', 'en/sub1', 'en/sub2', 'en/sub1/sub2']
00439 for c in testContexts:
00440 c = make_global_ns(c)
00441 testKey = 'param1'
00442 testVal = random.randint(-1000000, 100000)
00443 callerId = ns_join(c, "node")
00444 trueKey = ns_join(c, testKey)
00445 master.setParam(callerId, testKey, testVal)
00446 myState[trueKey] = testVal
00447
00448 v1 = self.apiSuccess(master.getParam('/', trueKey))
00449 v2 = self.apiSuccess(master.getParam(callerId, testKey))
00450 assert v1 == v2, "[%s]: %s vs. [%s,%s]: %s"%(trueKey, v1, callerId, testKey, v2)
00451 assert self.apiSuccess(master.hasParam(callerId, testKey)), testKey
00452 assert self.apiSuccess(master.hasParam('node', trueKey)), trueKey
00453
00454 self._checkParamState(myState)
00455
00456 def _testPrivateNames(self):
00457 master = self.master
00458 myState = {}
00459 self._checkParamState(myState)
00460
00461 testContexts = ['', 'sub1', 'sub1/sub2', 'sub1/sub2/sub3']
00462 for c in testContexts:
00463 c = make_global_ns(c)
00464 callerId = ns_join(c, "node")
00465
00466 keyStub = "param1"
00467 testKey = "~%s"%keyStub
00468 testVal = random.randint(-1000000, 100000)
00469 master.setParam(callerId, testKey, testVal)
00470 trueKey = ns_join(callerId, keyStub)
00471 myState[trueKey] = testVal
00472
00473 print("checking", trueKey)
00474 v1 = self.apiSuccess(master.getParam('/', trueKey))
00475 v2 = self.apiSuccess(master.getParam(callerId, testKey))
00476 assert v1 == v2, "[%s]: %s vs. [%s,%s]: %s"%(trueKey, v1, callerId, testKey, v2)
00477 assert self.apiSuccess(master.hasParam(callerId, testKey)), testKey
00478 assert self.apiSuccess(master.hasParam('node', trueKey)), trueKey
00479
00480
00481 testKey = ns_join("altnode","param2")
00482 testVal = random.randint(-1000000, 100000)
00483 master.setParam(callerId, testKey, testVal)
00484 trueKey = ns_join(c, testKey)
00485 altCallerId = ns_join(c, "altnode")
00486 myState[trueKey] = testVal
00487
00488 v1 = self.apiSuccess(master.getParam(altCallerId, "~param2"))
00489 v2 = self.apiSuccess(master.getParam(callerId, testKey))
00490 assert v1 == v2
00491 assert self.apiSuccess(master.hasParam(callerId, testKey)), testKey
00492 assert self.apiSuccess(master.hasParam(altCallerId, "~param2"))
00493
00494 self._checkParamState(myState)
00495
00496
00497 def _testScopeUp(self):
00498 master = self.master
00499 myState = {}
00500 self._checkParamState(myState)
00501
00502 testVal = random.randint(-1000000, 100000)
00503 master.setParam('/', 'uparam1', testVal)
00504 myState['/uparam1'] = testVal
00505 assert testVal == self.apiSuccess(master.getParam('/node', 'uparam1'))
00506 assert testVal == self.apiSuccess(master.getParam('/uptest/node', 'uparam1'))
00507 assert testVal == self.apiSuccess(master.getParam('/uptest/sub1/node', 'uparam1'))
00508 assert testVal == self.apiSuccess(master.getParam('/uptest/sub1/sub2/node', 'uparam1'))
00509
00510 testVal = random.randint(-1000000, 100000)
00511 master.setParam('/uptest2/sub1/node', 'uparam2', testVal)
00512 myState['/uptest2/sub1/uparam2'] = testVal
00513 assert testVal == self.apiSuccess(master.getParam('/uptest2/sub1/node', 'uparam2'))
00514 assert testVal == self.apiSuccess(master.getParam('/uptest2/sub1/sub2/node', 'uparam2'))
00515 assert testVal == self.apiSuccess(master.getParam('/uptest2/sub1/sub2/sub3/node', 'uparam2'))
00516
00517
00518 if 0:
00519 testVal = random.randint(-1000000, 100000)
00520 master.setParam('/uptest3/node', 'alt2/alt3/uparam3', testVal)
00521 myState['/uptest3/alt2/alt3/uparam3'] = testVal
00522 assert testVal == self.apiSuccess(master.getParam('/uptest3/sub1/node', 'alt2/alt3/uparam3'))
00523 assert testVal == self.apiSuccess(master.getParam('/uptest3/sub1/sub2/node', 'alt2/alt3/uparam3'))
00524 assert testVal == self.apiSuccess(master.getParam('/uptest3/sub1/sub2/sub3/node', 'alt2/alt3/uparam3'))
00525 self._checkParamState(myState)
00526
00527
00528 self.apiSuccess(master.deleteParam('/uptest/sub1/sub2/node', 'uparam1'))
00529 del myState['/uparam1']
00530 self._checkParamState(myState)
00531 self.apiSuccess(master.deleteParam('/uptest2/sub1/sub2/sub3/node', 'uparam2'))
00532 del myState['/uptest2/sub1/uparam2']
00533 if 0:
00534 self.apiSuccess(master.deleteParam('/uptest3/sub1/sub2/sub3/node', 'alt2/alt3/uparam3'))
00535 del myState['/uptest3/alt2/alt3/uparam3']
00536 self._checkParamState(myState)
00537
00538
00539 def _testScopeDown(self):
00540 master = self.master
00541 myState = {}
00542 self._checkParamState(myState)
00543
00544
00545 testVal = random.randint(-1000000, 100000)
00546 master.setParam('/down/one/two/three/node', 'dparam1', testVal)
00547 myState['/down/one/two/three/dparam1'] = testVal
00548 assert not self.apiSuccess(master.hasParam('/down/one/node', 'dparam1'))
00549 assert not self.apiSuccess(master.hasParam('/down/one/two/node', 'dparam1'))
00550 self.apiError(master.getParam('/down/one/node', 'dparam1'))
00551 self.apiError(master.getParam('/down/one/two/node', 'dparam1'))
00552
00553
00554 testVal = random.randint(-1000000, 100000)
00555 master.setParam('/', '/down2/dparam2', testVal)
00556 myState['/down2/dparam2'] = testVal
00557 assert testVal == self.apiSuccess(master.getParam('/down2/node', 'dparam2'))
00558 assert testVal == self.apiSuccess(master.getParam('/', 'down2/dparam2'))
00559 assert not self.apiSuccess(master.hasParam('/down2/node', 'down2/dparam2'))
00560 self.apiError(master.getParam('/down2/node', 'down2/dparam2'))
00561 self._checkParamState(myState)
00562
00563
00564 testVal = random.randint(-1000000, 100000)
00565 master.setParam('/', '/down3/sub/dparam3', testVal)
00566 myState['/down3/sub/dparam3'] = testVal
00567 assert testVal == self.apiSuccess(master.getParam('/down3/sub/node', 'dparam3'))
00568 assert testVal == self.apiSuccess(master.getParam('/down3/node', 'sub/dparam3'))
00569 assert testVal == self.apiSuccess(master.getParam('/', 'down3/sub/dparam3'))
00570 assert testVal == self.apiSuccess(master.getParam('/down3/sub/sub2/node', 'dparam3'))
00571 assert not self.apiSuccess(master.hasParam('/down3/sub/node', 'sub/dparam3'))
00572 assert not self.apiSuccess(master.hasParam('/down3/sub/node', 'down3/sub/dparam3'))
00573 self.apiError(master.getParam('/down3/sub/node', 'sub/dparam3'))
00574 self.apiError(master.getParam('/down3/sub/node', 'down3/sub/dparam3'))
00575 self._checkParamState(myState)
00576
00577
00578 master.setParam('/', '/down4/sub/dparam4A', testVal)
00579 self.apiSuccess(master.deleteParam('/down4/sub/node', 'dparam4A'))
00580 assert not self.apiSuccess(master.hasParam('/down4/sub', 'dparam4A'))
00581 master.setParam('/', '/down4/sub/dparam4B', testVal)
00582 self.apiSuccess(master.deleteParam('/down4/node', 'sub/dparam4B'))
00583 assert not self.apiSuccess(master.hasParam('/down4/sub', 'dparam4B'))
00584 master.setParam('/', '/down4/sub/dparam4C', testVal)
00585 self.apiSuccess(master.deleteParam('/', 'down4/sub/dparam4C'))
00586 assert not self.apiSuccess(master.hasParam('/down4/sub/node', 'dparam4C'))
00587 self._checkParamState(myState)
00588