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