示例#1
0
 def testMatchPathParent(self):
     tree = ServiceTree(_services)
     for i in _services:
         parentId = i.parentId if i.parentId else i.id
         expected = [tree.getService(parentId)]
         result = tree.matchServicePath(i.id, '..')
         self.assertEqual(result, expected)
示例#2
0
 def testMatchPathParent(self):
     tree = ServiceTree(_services)
     for i in _services:
         parentId = i.parentId if i.parentId else i.id
         expected = [tree.getService(parentId)]
         result = tree.matchServicePath(i.id, '..')
         self.assertEqual(result, expected)
示例#3
0
 def testMatchPathTag(self):
     tests = (
         ('zenoss', 'daemon', ('zope', )),
         ('zenoss', 'hub', ('hub1', 'hub2')),
         ('zenoss', 'xxx', ()),
     )
     tree = ServiceTree(_services)
     for service, tag, expected in tests:
         result = (i.id for i in tree.matchServicePath(service, tag))
         self.assertEqual(sorted(result), sorted(expected))
示例#4
0
 def testMatchPathName(self):
     tests = (
         ('zope', '/=ZOPE', ('zope', )),
         ('zenoss', '=HUB1', ('hub1', )),
         ('zope', '=HUB1', ()),
     )
     tree = ServiceTree(_services)
     for service, tag, expected in tests:
         result = (i.id for i in tree.matchServicePath(service, tag))
         self.assertEqual(sorted(result), sorted(expected))
示例#5
0
 def testMatchPathTag(self):
     tests = (
         ('zenoss', 'daemon',('zope',)),
         ('zenoss', 'hub',('hub1','hub2')),
         ('zenoss', 'xxx',()),
     )
     tree = ServiceTree(_services)
     for service, tag, expected in tests:
         result = (i.id for i in tree.matchServicePath(service, tag))
         self.assertEqual (sorted(result), sorted(expected))
示例#6
0
 def testMatchPathName(self):
     tests = (
         ('zope', '/=ZOPE', ('zope',)),
         ('zenoss', '=HUB1', ('hub1',)),
         ('zope', '=HUB1', ()),
     )
     tree = ServiceTree(_services)
     for service, tag, expected in tests:
         result = (i.id for i in tree.matchServicePath(service, tag))
         self.assertEqual(sorted(result), sorted(expected))
示例#7
0
 def testMatchPathComplex(self):
     tree = ServiceTree(_services)
     tests = (
         ('zenping', '../../hub', ('zenhub',)),
         ('zope', '../hub/collector', ('collector1','collector2', 'collector3')),
         ('hub1', './hub', ('zenhub',)),
         ('zope', '/', ('zenoss',)),
         ('zope', '/hub/collector', ('collector1','collector2', 'collector3')),
         ('zope', '/hub/=COLLECTOR1', ('collector1',)),
         ('zope', '/=HUB1/collector', ('collector1','collector2')),
     )
     for service, path, expected in tests:
         result = (i.id for i in tree.matchServicePath(service, path))
         self.assertEqual (sorted(result), sorted(expected),
                           "cwd:%s path:%s"%(service, path))
示例#8
0
 def testMatchPathComplex(self):
     tree = ServiceTree(_services)
     tests = (
         ('zenping', '../../hub', ('zenhub', )),
         ('zope', '../hub/collector', ('collector1', 'collector2',
                                       'collector3')),
         ('hub1', './hub', ('zenhub', )),
         ('zope', '/', ('zenoss', )),
         ('zope', '/hub/collector', ('collector1', 'collector2',
                                     'collector3')),
         ('zope', '/hub/=COLLECTOR1', ('collector1', )),
         ('zope', '/=HUB1/collector', ('collector1', 'collector2')),
     )
     for service, path, expected in tests:
         result = (i.id for i in tree.matchServicePath(service, path))
         self.assertEqual(sorted(result), sorted(expected),
                          "cwd:%s path:%s" % (service, path))
示例#9
0
 def testMatchPathRoot(self):
     tree = ServiceTree(_services)
     expected = ['zenoss']
     for service in ('zenoss', 'zope', 'zenping'):
         result = [i.id for i in tree.matchServicePath(service, '/')]
         self.assertEqual(result, expected)
示例#10
0
 def testMatchPathBadService(self):
     tree = ServiceTree(_services)
     with self.assertRaises(LookupError):
         tree.matchServicePath('BadServiceId', '/')
示例#11
0
 def testMatchPathCwd(self):
     tree = ServiceTree(_services)
     for service in ('zenoss', 'zope', 'zenping'):
         result = [i.id for i in tree.matchServicePath(service, '.')]
         self.assertEqual(result, [service])
示例#12
0
 def testMatchPathCwd(self):
     tree = ServiceTree(_services)
     for service in ('zenoss', 'zope', 'zenping'):
         result = [i.id for i in tree.matchServicePath(service, '.')]
         self.assertEqual(result, [service])
示例#13
0
 def testMatchPathRoot(self):
     tree = ServiceTree(_services)
     expected = ['zenoss']
     for service in ('zenoss', 'zope', 'zenping'):
         result = [i.id for i in tree.matchServicePath(service, '/')]
         self.assertEqual(result, expected)
示例#14
0
 def testMatchPathBadService(self):
     tree=ServiceTree(_services)
     with self.assertRaises(LookupError):
         tree.matchServicePath('BadServiceId', '/')