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 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)
Example #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)
Example #5
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))
Example #6
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))
Example #7
0
 def testGetServices(self):
     tree = ServiceTree(_services)
     for i in _services:
         self.assertEqual(tree.getService(i.id), i)
Example #8
0
 def testGetServices(self):
     tree=ServiceTree(_services)
     for i in _services:
         self.assertEqual(tree.getService(i.id), i)