X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=federation%2FTestCases.py;fp=federation%2FTestCases.py;h=c46e12f6840ecf4fa03f36e83b6be6d7bb6ca93b;hb=8bf032853c901e5978a079f1764aa94b3c0b672d;hp=0000000000000000000000000000000000000000;hpb=6761de2ff77e43e383300d92e2f12e5b15597353;p=tests.git diff --git a/federation/TestCases.py b/federation/TestCases.py new file mode 100755 index 0000000..c46e12f --- /dev/null +++ b/federation/TestCases.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +import sys + +class TestCases: + + def __init__ (self): + pass + + def initialize (self): + print "Performing : initialize" + print "current options",self.options + print "e.g. verbose=",self.options.verbose + + def cleanup (self): + print "Cleaning up" + + def testcase_1 (self): + print "\tRunning testcase 1" + + def testcase_2 (self): + print "\tRunning testcase 2" + + def testcase_3 (self): + print "\tRunning testcase 3" + + def testcase_standard (self): + print "\tRunning testcase standard" + + def main (self): + + from optparse import OptionParser + usage="""Usage: %prog [options] steps +steps can include + like in %prog 1 2+3""" + parser = OptionParser (usage=usage) + parser.add_option ("-v","--verbose",action="store_true", + dest="verbose",default=False, + help="run in verbose mode") + parser.add_option ("-a","--all",action="store_true", + dest="all",default=False, + help="Run all known testcases") + (self.options, args)=parser.parse_args() + + ### get the list of steps to run + steps=[] + if self.options.all: + # locates all local methods starting with "testcase_" + for method_name in dir(self): + # does it start with testcase_ + if (method_name.find('testcase_',0,len('testcase_'))==0): + print 'considering method',method_name + steps+=[method_name] + else: + for arg in args: + # support for the 2+3 syntax + steplist=arg.split("+") + for step in steplist: + steps += [ 'testcase_'+step] + + ### run them + # args contains the steps to run + for method_name in steps: + method=getattr(self,method_name) + if method: + print '============================== TestCases mainloop' + self.initialize() + method() + self.cleanup() + +if __name__ == "__main__": + TestCases().main()