class test_ClusterQueryMap(unittest.TestCase): _results = { "osr": { "nodeid": "/cluster/clusternode[hwid=1234]/@nodeid", "ip": "/cluster/clusternode[nodeid=1234]/eth[@name=eth0]/@ip", "ipconfig": [ "/cluster/clusternode[nodeid=1234]/eth[@name=eth0]/@ip", "/cluster/clusternode[nodeid=1234]/eth[@name=eth0]/@name" ] }, "redhatcluster": { "nodeid": "/cluster/clusternode[nodeid=1234]/com_info/eth[mac=1234]", "ip": "/cluster/clusternode[nodeid=1234]/com_info/eth/@ip" } } """ Unittests for Clustertools """ def setUp(self): """ set up data used in the tests. setUp is called before each test function execution. """ import sys import os.path testpath = os.path.dirname(sys.argv[0]) for _module in sys.modules.keys(): if _module.endswith("test_ClusterQueryMap"): testpath = os.path.dirname(sys.modules[_module].__file__) self.querymap = QueryMap() #print "testpath: %s" %testpath self.querymap.read(os.path.join(testpath, "test_ClusterQueryMap.txt")) def testOsr(self): self._test("osr") def testRedhatCluster(self): self._test("redhatcluster") def _test(self, section): self.querymap.mainsection = section params = ["1234", "eth0"] for param in self._results[section]: _result1 = self._results[section][param] _result2 = self.querymap.get(None, param, False) if isinstance(_result2, basestring): _result2 = _result2 % self.querymap.array2params(params) else: for i in range(len(_result2)): _result2[i] = _result2[i] % self.querymap.array2params( params) print "%s == %s" % (_result1, _result2) self.assertEqual(_result1, _result2)
def setUp(self): """ set up data used in the tests. setUp is called before each test function execution. """ import sys import os.path testpath = os.path.dirname(sys.argv[0]) for _module in sys.modules.keys(): if _module.endswith("test_ClusterQueryMap"): testpath = os.path.dirname(sys.modules[_module].__file__) self.querymap = QueryMap() #print "testpath: %s" %testpath self.querymap.read(os.path.join(testpath, "test_ClusterQueryMap.txt"))
class test_ClusterQueryMap(unittest.TestCase): _results={ "osr": { "nodeid": "/cluster/clusternode[hwid=1234]/@nodeid", "ip": "/cluster/clusternode[nodeid=1234]/eth[@name=eth0]/@ip", "ipconfig": [ "/cluster/clusternode[nodeid=1234]/eth[@name=eth0]/@ip", "/cluster/clusternode[nodeid=1234]/eth[@name=eth0]/@name" ]}, "redhatcluster": { "nodeid": "/cluster/clusternode[nodeid=1234]/com_info/eth[mac=1234]", "ip": "/cluster/clusternode[nodeid=1234]/com_info/eth/@ip" }} """ Unittests for Clustertools """ def setUp(self): """ set up data used in the tests. setUp is called before each test function execution. """ import sys import os.path testpath=os.path.dirname(sys.argv[0]) for _module in sys.modules.keys(): if _module.endswith("test_ClusterQueryMap"): testpath=os.path.dirname(sys.modules[_module].__file__) self.querymap=QueryMap() #print "testpath: %s" %testpath self.querymap.read(os.path.join(testpath,"test_ClusterQueryMap.txt")) def testOsr(self): self._test("osr") def testRedhatCluster(self): self._test("redhatcluster") def _test(self, section): self.querymap.mainsection=section params=["1234", "eth0"] for param in self._results[section]: _result1=self._results[section][param] _result2=self.querymap.get(None, param, False) if isinstance(_result2, basestring): _result2= _result2 % self.querymap.array2params(params) else: for i in range(len(_result2)): _result2[i]=_result2[i] % self.querymap.array2params(params) print "%s == %s" %(_result1, _result2) self.assertEqual(_result1, _result2)
def setUp(self): """ set up data used in the tests. setUp is called before each test function execution. """ import sys import os.path testpath=os.path.dirname(sys.argv[0]) for _module in sys.modules.keys(): if _module.endswith("test_ClusterQueryMap"): testpath=os.path.dirname(sys.modules[_module].__file__) self.querymap=QueryMap() #print "testpath: %s" %testpath self.querymap.read(os.path.join(testpath,"test_ClusterQueryMap.txt"))