• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

contrib/opal/ZSI/test/wsdl2py/runTests.py

00001 #!/usr/bin/env python
00002 ############################################################################
00003 # Joshua R. Boverhof, LBNL
00004 # See Copyright for copyright notice!
00005 ###########################################################################
00006 import unittest, warnings, os
00007 from ZSI import version
00008 from ZSI.wstools.logging import gridLog
00009 from ServiceTest import main, CONFIG_PARSER, DOCUMENT, LITERAL, BROKE, TESTS
00010 
00011 os.environ['GRIDLOG_ON'] = '1'
00012 os.environ['GRIDLOG_DEST'] = "gridlog-udp://portnoy.lbl.gov:15100"
00013 
00014 # General targets
00015 def dispatch():
00016     """Run all dispatch tests"""
00017     return _dispatchTestSuite(broke=False)
00018 
00019 def local():
00020     """Run all local tests"""
00021     return _localTestSuite(broke=False)
00022     
00023 def net():
00024     """Run all network tests"""
00025     return _netTestSuite(broke=False)
00026     
00027 def all():
00028     """Run all tests"""
00029     return _allTestSuite(broke=False)
00030 
00031 
00032 # Specialized binding targets
00033 def docLitTestSuite():
00034     """Run all doc/lit network tests"""
00035     return _netTestSuite(broke=False, document=True, literal=True)
00036 
00037 def rpcLitTestSuite():
00038     """Run all rpc/lit network tests"""
00039     return _netTestSuite(broke=False, document=False, literal=True)
00040 
00041 def rpcEncTestSuite():
00042     """Run all rpc/enc network tests"""
00043     return _netTestSuite(broke=False, document=False, literal=False)
00044     
00045     
00046 # Low level functions
00047 def _allTestSuite(document=None, literal=None, broke=None):
00048     return _makeTestSuite('all', document, literal, broke)
00049 
00050 def _netTestSuite(document=None, literal=None, broke=None):
00051     return _makeTestSuite('net', document, literal, broke)
00052 
00053 def _localTestSuite(document=None, literal=None, broke=None):
00054     return _makeTestSuite('local', document, literal, broke)
00055     
00056 def _dispatchTestSuite(document=None, literal=None, broke=None):
00057     return _makeTestSuite('dispatch', document, literal, broke)
00058 
00059     
00060 def _makeTestSuite(test, document=None, literal=None, broke=None):
00061     """Return a test suite containing all test cases that satisfy 
00062     the parameters. None means don't check.
00063     
00064     Parameters:
00065        test -- "net" run network tests, "local" run local tests,
00066            "dispatch" run dispatch tests, "all" run all tests.
00067        document -- None, True, False
00068        literal -- None, True, False
00069        broke -- None, True, False
00070     """
00071     assert test in ['net', 'local', 'dispatch', 'all'],(
00072         'test must be net, local, dispatch, or all')
00073     
00074     cp = CONFIG_PARSER
00075     testSections = []
00076     sections = [\
00077         'rpc_encoded' , 'rpc_encoded_broke',
00078         'rpc_literal', 'rpc_literal_broke', 'rpc_literal_broke_interop',
00079         'doc_literal', 'doc_literal_broke', 'doc_literal_broke_interop',
00080     ]
00081     boo = cp.getboolean
00082     for s,d,l,b in map(\
00083         lambda sec: \
00084             (sec, (None,boo(sec,DOCUMENT)), (None,boo(sec,LITERAL)), (None,boo(sec,BROKE))), sections):
00085         if document in d and literal in l and broke in b:
00086             testSections.append(s)
00087         
00088     suite = unittest.TestSuite()
00089     for section in testSections:
00090         moduleList = cp.get(section, TESTS).split()
00091         for module in  map(__import__, moduleList):
00092             def _warn_empty():
00093                 warnings.warn('"%s" has no test "%s"' %(module, test))
00094                 return unittest.TestSuite()
00095                 
00096             s = getattr(module, test, _warn_empty)()
00097             suite.addTest(s)
00098     return suite
00099 
00100    
00101 if __name__ == "__main__": 
00102     gridLog(prog="runTests.py", zsi="v%d.%d.%d" % version.Version, event="zsi.test.wsdl2py.runTests.ping")
00103     main()
00104     
00105 

Generated on Wed Oct 20 2010 11:12:16 for APBS by  doxygen 1.7.2