test_WSDLReader.py 2.0 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python
  2. ############################################################################
  3. # Joshua R. Boverhof, David W. Robertson, LBNL
  4. # See Copyright for copyright notice!
  5. ###########################################################################
  6. import unittest, sys, copy
  7. from ConfigParser import NoOptionError
  8. import utils
  9. from ZSI.wstools.WSDLTools import WSDLReader
  10. """
  11. Unittest for the wstools WSDLReader class
  12. """
  13. class WSDLReaderTestCase(unittest.TestCase):
  14. def __init__(self, methodName='runTest'):
  15. global configLoader
  16. unittest.TestCase.__init__(self, methodName)
  17. def setUp(self):
  18. # not thread safe
  19. self.path = configLoader.nameGenerator.next()
  20. print self.path
  21. sys.stdout.flush()
  22. def __str__(self):
  23. teststr = unittest.TestCase.__str__(self)
  24. if hasattr(self, "path"):
  25. self.printedOut = True
  26. return "%s: %s" % (teststr, self.path )
  27. else:
  28. return "%s" % (teststr)
  29. def test_WSDLReader(self):
  30. if self.path[:7] == 'http://':
  31. wsdl = WSDLReader().loadFromURL(self.path)
  32. else:
  33. wsdl = WSDLReader().loadFromFile(self.path)
  34. def makeTestSuite(topLevel=False, config=None):
  35. global configLoader
  36. suite = unittest.TestSuite()
  37. if not hasattr(sys.modules[__name__], "configLoader"):
  38. if not config:
  39. configLoader = utils.MatchTestLoader(False, "config.py",
  40. "WSDLReaderTestCase")
  41. else:
  42. configLoader = config
  43. configLoader.testMethodPrefix = "test"
  44. # need to have as command-line argument
  45. suite.addTest(configLoader.loadTestsFromConfig(WSDLReaderTestCase,
  46. "services_by_http"))
  47. return suite
  48. def main():
  49. global configLoader
  50. configLoader = utils.MatchTestLoader(False, "config.py", "makeTestSuite")
  51. unittest.main(defaultTest="makeTestSuite", testLoader=configLoader)
  52. if __name__ == "__main__" : main()