configuration file.main
| @@ -1,156 +1,20 @@ | |||||
| #!/usr/bin/env python | |||||
| import unittest, sys | |||||
| from ConfigParser import ConfigParser | |||||
| from ZSI.wstools.WSDLTools import WSDLReader | |||||
| from test_wsdl import WSDLToolsTestCase, NETWORK, STANDALONE | |||||
| CONFIG = None | |||||
| class HomeLandSecurityTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'homelandsecurity' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class Rtf2htmlTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'rtf2html' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class AmazonTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'amazon' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class AirportTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'airport' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class OGSITestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'ogsi' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class BooksTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'books' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class DistanceTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'distance' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class FreeDBTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'freedb' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class GlobalWeatherTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'globalweather' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class IHaddockTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'IHaddock' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class Ip2geoTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'ip2geo' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class MagicTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'magic' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class QueryTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'query' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class RateInfoTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'RateInfo' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class SHA1EncryptTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'SHA1Encrypt' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class SiteInspectTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'siteInspect' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class SolveSystemsTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'SolveSystem' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class TemperatureServiceTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'TemperatureService' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class USweatherTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'usweather' | |||||
| self.loadFromConfig(CONFIG) | |||||
| class Zip2geoTestCase(WSDLToolsTestCase): | |||||
| def test(self): | |||||
| self.option = 'zip2geo' | |||||
| self.loadFromConfig(CONFIG) | |||||
| CASES = [AirportTestCase, | |||||
| AmazonTestCase, | |||||
| BooksTestCase, | |||||
| DistanceTestCase, | |||||
| FreeDBTestCase, | |||||
| GlobalWeatherTestCase, | |||||
| HomeLandSecurityTestCase, | |||||
| IHaddockTestCase, | |||||
| Ip2geoTestCase, | |||||
| MagicTestCase, | |||||
| OGSITestCase, | |||||
| QueryTestCase, | |||||
| RateInfoTestCase, | |||||
| Rtf2htmlTestCase, | |||||
| SHA1EncryptTestCase, | |||||
| SiteInspectTestCase, | |||||
| SolveSystemsTestCase, | |||||
| TemperatureServiceTestCase, | |||||
| USweatherTestCase, | |||||
| WSDLToolsTestCase, | |||||
| Zip2geoTestCase] | |||||
| def makeNetworkSuite(): | |||||
| return getSuite(NETWORK) | |||||
| def makeStandAloneSuite(): | |||||
| return getSuite(STANDALONE) | |||||
| def getSuite(section): | |||||
| tests = [] | |||||
| ############################################################################ | |||||
| # Joshua R. Boverhof, David W. Robertson, LBNL | |||||
| # See LBNLCopyright for copyright notice! | |||||
| ########################################################################### | |||||
| import unittest | |||||
| import test_wsdl | |||||
| import utils | |||||
| def makeTestSuite(): | |||||
| suite = unittest.TestSuite() | suite = unittest.TestSuite() | ||||
| loader = unittest.TestLoader() | |||||
| WSDLToolsTestCase.section = section | |||||
| for case in CASES: | |||||
| #case.section = section | |||||
| test = loader.loadTestsFromTestCase(case) | |||||
| tests.append(test) | |||||
| suite.addTests(tests) | |||||
| suite.addTest(test_wsdl.makeTestSuite("services_by_file")) | |||||
| return suite | return suite | ||||
| def main(): | def main(): | ||||
| global CONFIG | |||||
| from test_wstools import CONFIG_FILE | |||||
| CONFIG = ConfigParser() | |||||
| CONFIG.read(CONFIG_FILE) | |||||
| unittest.TestProgram(defaultTest='makeStandAloneSuite') | |||||
| loader = utils.MatchTestLoader(True, None, "makeTestSuite") | |||||
| unittest.main(defaultTest="makeTestSuite", testLoader=loader) | |||||
| if __name__ == "__main__" : main() | if __name__ == "__main__" : main() | ||||
| @@ -1,49 +1,37 @@ | |||||
| #!/usr/bin/env python | #!/usr/bin/env python | ||||
| import unittest, sys | |||||
| from ConfigParser import NoOptionError | |||||
| from ZSI.wstools.WSDLTools import WSDLReader | |||||
| from ZSI.wstools.Utility import DOM | |||||
| CONFIG = None | |||||
| NETWORK = 'services_by_http' | |||||
| STANDALONE = 'services_by_file' | |||||
| ############################################################################ | |||||
| # Joshua R. Boverhof, David W. Robertson, LBNL | |||||
| # See LBNLCopyright for copyright notice! | |||||
| ########################################################################### | |||||
| import sys, unittest | |||||
| from ZSI.wstools.Utility import DOM | |||||
| import utils | |||||
| class WSDLToolsTestCase(unittest.TestCase): | class WSDLToolsTestCase(unittest.TestCase): | ||||
| def __init__(self, methodName='runTest'): | def __init__(self, methodName='runTest'): | ||||
| unittest.TestCase.__init__(self, methodName) | unittest.TestCase.__init__(self, methodName) | ||||
| def setUp(self): | def setUp(self): | ||||
| pass | |||||
| def tearDown(self): | |||||
| if self.wsdl: | |||||
| self.wsdlServices() | |||||
| self.wsdlMessages() | |||||
| self.wsdlPortTypes() | |||||
| self.wsdlBindings() | |||||
| self.wsdlImports() | |||||
| self.wsdlExtensions() | |||||
| self.wsdlTypes() | |||||
| def loadFromConfig(self, config=CONFIG): | |||||
| self.wsdl = None | |||||
| try: | |||||
| path = config.get(self.section, self.option) | |||||
| except NoOptionError, ex: | |||||
| pass | |||||
| else: | |||||
| if path[:7] == 'http://': | |||||
| self.loadFromURL(url=path) | |||||
| else: | |||||
| self.loadFromFile(file=path) | |||||
| def loadFromFile(self, file): | |||||
| self.wsdl = WSDLReader().loadFromFile(file) | |||||
| global configLoader | |||||
| # not thread safe | |||||
| self.path = configLoader.nameGenerator.next() | |||||
| print self.path | |||||
| sys.stdout.flush() | |||||
| def loadFromURL(self, url): | |||||
| self.wsdl = WSDLReader().loadFromURL(url) | |||||
| def __str__(self): | |||||
| teststr = unittest.TestCase.__str__(self) | |||||
| if hasattr(self, "path"): | |||||
| return "%s: %s" % (teststr, self.path ) | |||||
| else: | |||||
| return "%s" % (teststr) | |||||
| def checkWSDLCollection(self, tag_name, component, key='name'): | def checkWSDLCollection(self, tag_name, component, key='name'): | ||||
| if self.wsdl is None: | |||||
| return | |||||
| definition = self.wsdl.document.documentElement | definition = self.wsdl.document.documentElement | ||||
| version = DOM.WSDLUriToVersion(definition.namespaceURI) | version = DOM.WSDLUriToVersion(definition.namespaceURI) | ||||
| nspname = DOM.GetWSDLUri(version) | nspname = DOM.GetWSDLUri(version) | ||||
| @@ -57,39 +45,63 @@ class WSDLToolsTestCase(unittest.TestCase): | |||||
| name = DOM.getAttr(cnode, key) | name = DOM.getAttr(cnode, key) | ||||
| component[name] | component[name] | ||||
| def wsdlServices(self): | |||||
| self.checkWSDLCollection('service', self.wsdl.services) | |||||
| def wsdlTestAll(self): | |||||
| try: | |||||
| self.wsdl = utils.setUpWsdl(self.path) | |||||
| except: | |||||
| self.path = self.path + ": load failed, unable to start" | |||||
| raise | |||||
| try: | |||||
| self.checkWSDLCollection('service', self.wsdl.services) | |||||
| except: | |||||
| self.path = self.path + ": wsdl.services" | |||||
| raise | |||||
| def wsdlMessages(self): | |||||
| self.checkWSDLCollection('message', self.wsdl.messages) | |||||
| try: | |||||
| self.checkWSDLCollection('message', self.wsdl.messages) | |||||
| except: | |||||
| self.path = self.path + ": wsdl.messages" | |||||
| raise | |||||
| def wsdlPortTypes(self): | |||||
| self.checkWSDLCollection('portType', self.wsdl.portTypes) | |||||
| try: | |||||
| self.checkWSDLCollection('portType', self.wsdl.portTypes) | |||||
| except: | |||||
| self.path = self.path + ": wsdl.portTypes" | |||||
| raise | |||||
| def wsdlBindings(self): | |||||
| self.checkWSDLCollection('binding', self.wsdl.bindings) | |||||
| try: | |||||
| self.checkWSDLCollection('binding', self.wsdl.bindings) | |||||
| except: | |||||
| self.path = self.path + ": wsdl.bindings" | |||||
| raise | |||||
| def wsdlImports(self): | |||||
| self.checkWSDLCollection('import', self.wsdl.imports, key='namespace') | |||||
| try: | |||||
| self.checkWSDLCollection('import', self.wsdl.imports, key='namespace') | |||||
| except: | |||||
| self.path = self.path + ": wsdl.imports" | |||||
| raise | |||||
| def wsdlTypes(self): | |||||
| for key in self.wsdl.types.keys(): | |||||
| schema = self.wsdl.types[key] | |||||
| self.failUnlessEqual(key, schema.getTargetNamespace()) | |||||
| try: | |||||
| for key in self.wsdl.types.keys(): | |||||
| schema = self.wsdl.types[key] | |||||
| self.failUnlessEqual(key, schema.getTargetNamespace()) | |||||
| definition = self.wsdl.document.documentElement | |||||
| version = DOM.WSDLUriToVersion(definition.namespaceURI) | |||||
| nspname = DOM.GetWSDLUri(version) | |||||
| for node in DOM.getElements(definition, 'types', nspname): | |||||
| for snode in DOM.getElements(node, 'schema'): | |||||
| tns = DOM.findTargetNS(snode) | |||||
| schema = self.wsdl.types[tns] | |||||
| self.schemaAttributesDeclarations(schema, snode) | |||||
| self.schemaAttributeGroupDeclarations(schema, snode) | |||||
| self.schemaElementDeclarations(schema, snode) | |||||
| self.schemaTypeDefinitions(schema, snode) | |||||
| except: | |||||
| self.path = self.path + ": wsdl.types" | |||||
| raise | |||||
| definition = self.wsdl.document.documentElement | |||||
| version = DOM.WSDLUriToVersion(definition.namespaceURI) | |||||
| nspname = DOM.GetWSDLUri(version) | |||||
| for node in DOM.getElements(definition, 'types', nspname): | |||||
| for snode in DOM.getElements(node, 'schema'): | |||||
| tns = DOM.findTargetNS(snode) | |||||
| schema = self.wsdl.types[tns] | |||||
| self.schemaAttributesDeclarations(schema, snode) | |||||
| self.schemaAttributeGroupDeclarations(schema, snode) | |||||
| self.schemaElementDeclarations(schema, snode) | |||||
| self.schemaTypeDefinitions(schema, snode) | |||||
| def wsdlExtensions(self): | |||||
| if self.wsdl.extensions: | if self.wsdl.extensions: | ||||
| print 'No check for WSDLTools(%s) Extensions:' %(self.wsdl.name) | print 'No check for WSDLTools(%s) Extensions:' %(self.wsdl.name) | ||||
| for ext in self.wsdl.extensions: print '\t', ext | for ext in self.wsdl.extensions: print '\t', ext | ||||
| @@ -108,30 +120,25 @@ class WSDLToolsTestCase(unittest.TestCase): | |||||
| self.checkXSDCollection('simpleType', schema.types, node) | self.checkXSDCollection('simpleType', schema.types, node) | ||||
| def makeNetworkSuite(): | |||||
| return getSuite(section='services_by_http') | |||||
| def makeStandAloneSuite(): | |||||
| return getSuite('services_by_file') | |||||
| def makeTestSuite(section=None): | |||||
| global configLoader | |||||
| def getSuite(section): | |||||
| names = CONFIG.options(section) | |||||
| tests = [] | |||||
| suite = unittest.TestSuite() | suite = unittest.TestSuite() | ||||
| loader = unittest.TestLoader() | |||||
| WSDLToolsTestCase.section = section | |||||
| for case in [WSDLToolsTestCase,]: | |||||
| case.section = section | |||||
| test = loader.loadTestsFromTestCase(case) | |||||
| tests.append(test) | |||||
| #tests.sort() | |||||
| suite.addTests(tests) | |||||
| configLoader = utils.MatchTestLoader(False, "config.py", "WSDLToolsTestCase") | |||||
| if not section: | |||||
| found = configLoader.setSection(sys.argv) | |||||
| if not found: | |||||
| configLoader.setSection("services_by_http") | |||||
| else: | |||||
| configLoader.setSection(section) | |||||
| configLoader.testMethodPrefix = "wsdlTest" | |||||
| suite.addTest(configLoader.loadTestsFromConfig(WSDLToolsTestCase)) | |||||
| return suite | return suite | ||||
| #makeTestSuite = makeStandAloneSuite | |||||
| #def main(): | |||||
| # unittest.main(defaultTest="makeTestSuite") | |||||
| def main(): | |||||
| loader = utils.MatchTestLoader(False, None, "makeTestSuite") | |||||
| unittest.main(defaultTest="makeTestSuite", testLoader=loader) | |||||
| if __name__ == "__main__" : main() | if __name__ == "__main__" : main() | ||||
| @@ -1,23 +1,39 @@ | |||||
| #!/usr/bin/env python | #!/usr/bin/env python | ||||
| ############################################################################ | |||||
| # Joshua R. Boverhof, David W. Robertson, LBNL | |||||
| # See LBNLCopyright for copyright notice! | |||||
| ########################################################################### | |||||
| import unittest, tarfile, os, ConfigParser | import unittest, tarfile, os, ConfigParser | ||||
| import test_t1 | |||||
| import test_wsdl | |||||
| import utils | |||||
| SECTION='files' | SECTION='files' | ||||
| CONFIG_FILE = 'config.py' | CONFIG_FILE = 'config.py' | ||||
| def main(): | |||||
| def extractFiles(section, option): | |||||
| config = ConfigParser.ConfigParser() | config = ConfigParser.ConfigParser() | ||||
| config.read(CONFIG_FILE) | config.read(CONFIG_FILE) | ||||
| archives = config.get(SECTION, 'archives') | |||||
| archives = config.get(section, option) | |||||
| archives = eval(archives) | archives = eval(archives) | ||||
| test_t1.CONFIG = config | |||||
| for file in archives: | for file in archives: | ||||
| tar = tarfile.open(file) | tar = tarfile.open(file) | ||||
| if not os.access(tar.membernames[0], os.R_OK): | if not os.access(tar.membernames[0], os.R_OK): | ||||
| for i in tar.getnames(): | for i in tar.getnames(): | ||||
| tar.extract(i) | tar.extract(i) | ||||
| unittest.TestProgram(defaultTest='test_t1.makeStandAloneSuite') | |||||
| def makeTestSuite(): | |||||
| suite = unittest.TestSuite() | |||||
| suite.addTest(test_wsdl.makeTestSuite("services_by_file")) | |||||
| return suite | |||||
| def main(): | |||||
| extractFiles(SECTION, 'archives') | |||||
| loader = utils.MatchTestLoader(True, None, "makeTestSuite") | |||||
| unittest.main(defaultTest="makeTestSuite", testLoader=loader) | |||||
| if __name__ == "__main__" : main() | if __name__ == "__main__" : main() | ||||
| @@ -1,14 +1,22 @@ | |||||
| #!/usr/bin/env python | #!/usr/bin/env python | ||||
| import unittest, tarfile, os, ConfigParser | |||||
| import test_t1 | |||||
| CONFIG_FILE = 'config.py' | |||||
| ############################################################################ | |||||
| # Joshua R. Boverhof, David W. Robertson, LBNL | |||||
| # See LBNLCopyright for copyright notice! | |||||
| ########################################################################### | |||||
| import unittest | |||||
| import test_wsdl | |||||
| import utils | |||||
| def main(): | |||||
| config = ConfigParser.ConfigParser() | |||||
| config.read(CONFIG_FILE) | |||||
| test_t1.CONFIG = config | |||||
| unittest.TestProgram(defaultTest='test_t1.makeNetworkSuite') | |||||
| def makeTestSuite(): | |||||
| suite = unittest.TestSuite() | |||||
| suite.addTest(test_wsdl.makeTestSuite(("no_schemas", "simpleTypes", "services_by_http"))) | |||||
| return suite | |||||
| def main(): | |||||
| loader = utils.MatchTestLoader(True, None, "makeTestSuite") | |||||
| unittest.main(defaultTest="makeTestSuite", testLoader=loader) | |||||
| if __name__ == "__main__" : main() | if __name__ == "__main__" : main() | ||||