Example #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)
Example #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)
Example #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))
Example #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))
Example #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))
Example #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))
Example #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))
Example #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))
Example #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)
Example #10
0
 def testMatchPathBadService(self):
     tree = ServiceTree(_services)
     with self.assertRaises(LookupError):
         tree.matchServicePath('BadServiceId', '/')
Example #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])
Example #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])
Example #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)
Example #14
0
 def testMatchPathBadService(self):
     tree=ServiceTree(_services)
     with self.assertRaises(LookupError):
         tree.matchServicePath('BadServiceId', '/')