Пример #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 testGetPath(self):
     tree = ServiceTree(_services)
     tests = (('zenoss', '/zenoss'),
              ('zenping', '/zenoss/hub1/collector1/zenping'))
     for service, expected in tests:
         path = tree.getPath(tree.getService(service))
         actual = '/'+'/'.join(i.id for i in path)
         self.assertEqual(actual, expected)
Пример #4
0
 def testGetPath(self):
     tree = ServiceTree(_services)
     tests = (('zenoss', '/zenoss'), ('zenping',
                                      '/zenoss/hub1/collector1/zenping'))
     for service, expected in tests:
         path = tree.getPath(tree.getService(service))
         actual = '/' + '/'.join(i.id for i in path)
         self.assertEqual(actual, expected)
Пример #5
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))
Пример #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 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))
Пример #8
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))
Пример #9
0
 def testFindMatchingServices(self):
     tree = ServiceTree(_services)
     tests = (
         ('zenoss', 'collector', ('zenping', 'collector1', 'zencommand', 'collector2', 'collector3')),
         ('hub1', 'collector', ('zenping', 'collector1', 'zencommand', 'collector2')),
         ('zenoss', '=HUB1', ('hub1',)),
     )
     for service, pattern, expected in tests:
         root = tree.getService(service)
         result = [i.id for i in tree.findMatchingServices(root, pattern)]
         self.assertEqual(sorted(result), sorted(expected))
Пример #10
0
 def testFindMatchingServices(self):
     tree = ServiceTree(_services)
     tests = (
         ('zenoss', 'collector', ('zenping', 'collector1', 'zencommand',
                                  'collector2', 'collector3')),
         ('hub1', 'collector', ('zenping', 'collector1', 'zencommand',
                                'collector2')),
         ('zenoss', '=HUB1', ('hub1', )),
     )
     for service, pattern, expected in tests:
         root = tree.getService(service)
         result = [i.id for i in tree.findMatchingServices(root, pattern)]
         self.assertEqual(sorted(result), sorted(expected))
Пример #11
0
 def testGetChildren(self):
     _children = (
         ('zenoss', ('zope', 'hub1', 'hub2')),
         ('zope', ()),
         ('hub1', ('zenhub', 'collector1', 'collector2')),
         ('zenhub', ()),
         ('collector1', ('zenping',)),
         ('zenping', ()),
     )
     tree=ServiceTree(_services)
     for service, expectedChildren in (_children):
         children = [i.id for i in tree.getChildren(service)]
         self.assertEqual(sorted(children), sorted(expectedChildren),
                          '%s != %s' %(sorted(children),sorted(expectedChildren)))
Пример #12
0
 def testGetChildren(self):
     _children = (
         ('zenoss', ('zope', 'hub1', 'hub2')),
         ('zope', ()),
         ('hub1', ('zenhub', 'collector1', 'collector2')),
         ('zenhub', ()),
         ('collector1', ('zenping', )),
         ('zenping', ()),
     )
     tree = ServiceTree(_services)
     for service, expectedChildren in (_children):
         children = [i.id for i in tree.getChildren(service)]
         self.assertEqual(
             sorted(children), sorted(expectedChildren),
             '%s != %s' % (sorted(children), sorted(expectedChildren)))
Пример #13
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))
Пример #14
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))
Пример #15
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])
Пример #16
0
 def testMatchPathBadService(self):
     tree = ServiceTree(_services)
     with self.assertRaises(LookupError):
         tree.matchServicePath('BadServiceId', '/')
Пример #17
0
 def testGetServices(self):
     tree = ServiceTree(_services)
     for i in _services:
         self.assertEqual(tree.getService(i.id), i)
Пример #18
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)
Пример #19
0
 def testGetServices(self):
     tree=ServiceTree(_services)
     for i in _services:
         self.assertEqual(tree.getService(i.id), i)
Пример #20
0
 def testMatchPathBadService(self):
     tree=ServiceTree(_services)
     with self.assertRaises(LookupError):
         tree.matchServicePath('BadServiceId', '/')
Пример #21
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)
Пример #22
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])