X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=test%2Flib%2Ftest_utils.py;h=ed9be1216dc1c6d10b92b5d4b7a58d37de9f31f2;hb=88c5b86c62dbaef9e3b2a73bf08b6c21075e12a3;hp=958cfc0a0b227c5623a47dcffe6460fbdc2713c9;hpb=0b2ce43bb7573f766bb348117d089e81d2a395ff;p=nepi.git diff --git a/test/lib/test_utils.py b/test/lib/test_utils.py index 958cfc0a..ed9be121 100644 --- a/test/lib/test_utils.py +++ b/test/lib/test_utils.py @@ -30,9 +30,12 @@ class DummyEC(object): def create_node(hostname, username = None, identity = None): ec = DummyEC() node = LinuxNode(ec, 1) + node.set("hostname", hostname) + if username: node.set("username", username) + if identity: node.set("identity", identity) @@ -44,18 +47,18 @@ def create_node(hostname, username = None, identity = None): def skipIfNotAlive(func): name = func.__name__ def wrapped(*args, **kwargs): - host = args[1] - if host != "localhost": - user = None + hostname = args[1] + if hostname != "localhost": + username = None identity = None if len(args) >= 3: - user = args[2] + username = args[2] if len(args) >= 4: identity = args[3] - node, ec = create_node(host, user, identity) + node, ec = create_node(hostname, username, identity) if not node.is_alive(): print "*** WARNING: Skipping test %s: Node %s is not alive\n" % ( @@ -71,6 +74,7 @@ def skipIfAnyNotAlive(func): def wrapped(*args, **kwargs): argss = list(args) argss.pop(0) + for i in xrange(len(argss)/2): username = argss[i*2] hostname = argss[i*2+1] @@ -85,6 +89,28 @@ def skipIfAnyNotAlive(func): return wrapped +def skipIfAnyNotAliveWithIdentity(func): + name = func.__name__ + def wrapped(*args, **kwargs): + argss = list(args) + argss.pop(0) + for i in xrange(len(argss)/3): + username = argss[i*3] + hostname = argss[i*3+1] + identity = argss[i*3+2] + + node, ec = create_node(hostname, username, identity) + + if not node.is_alive(): + print "*** WARNING: Skipping test %s: Node %s is not alive\n" % ( + name, node.get("hostname")) + return + + return func(*args, **kwargs) + + return wrapped + + def skipInteractive(func): name = func.__name__ def wrapped(*args, **kwargs):