ZSI-specific material to zsi/test/wsdlpy, removed dependencies on utils.py.main
@@ -1,25 +1,23 @@ | |||||
Two top level modules have been provided to run the tests. "test_wstools.py" is used | |||||
to run all of the local tests. "test_wstools_net.py" is used to run all of the | |||||
tests that require network access. | |||||
Two top level modules have been provided to run the tests. "test_wstools.py" | |||||
is used to run all of the local tests. "test_wstools_net.py" is used to run | |||||
all of the tests that require network access. | |||||
TESTS: | |||||
test_t1 -- Basic test, just checks that wsdl and xsd objects are in the | |||||
right places. | |||||
Add the -v option for more informative feedback. | |||||
ADDING TESTS: | ADDING TESTS: | ||||
1. For Stand-Alone tests add WSDL FILE to appropriate archive file | 1. For Stand-Alone tests add WSDL FILE to appropriate archive file | ||||
Need to add a NEW Archive?: | Need to add a NEW Archive?: | ||||
config.py [files] "archive" -- tuple of all archive files, | |||||
config.txt [files] "archive" -- tuple of all archive files, | |||||
if you need to create a new archive append the archive | if you need to create a new archive append the archive | ||||
name to the 'archive' tuple. | name to the 'archive' tuple. | ||||
2. Edit config.py section(s): | |||||
2. Edit config.txt section(s): | |||||
option -- name by which service will be referenced in test case. | option -- name by which service will be referenced in test case. | ||||
Need an entry under appropriate section(s), this name | Need an entry under appropriate section(s), this name | ||||
must be unique within each section it appears but it may | must be unique within each section it appears but it may | ||||
appear in multiple sections. | appear in multiple sections. | ||||
config.py "test" sections: | |||||
config.txt "test" sections: | |||||
Stand-Alone -- add "option" under [services_by_file] | Stand-Alone -- add "option" under [services_by_file] | ||||
eg. amazon = exports/AmazonWebServices.wsdl | eg. amazon = exports/AmazonWebServices.wsdl | ||||
@@ -28,21 +26,7 @@ ADDING TESTS: | |||||
Broken -- add "option" under [broken] | Broken -- add "option" under [broken] | ||||
3. In test module(s) | |||||
a. Add test case: | |||||
#eg. test_t1.py | |||||
class AmazonTestCase(WSDLToolsTestCase): | |||||
def test(self): | |||||
self.option = 'amazon' | |||||
self.loadFromConfig(CONFIG) | |||||
b. Add class name of test case to CASES list. | |||||
CASES = [AirportTestCase, | |||||
AmazonTestCase, | |||||
.... etc | |||||
4. Done | |||||
3. Done | |||||
CONTENTS OF SAMPLE WSDL/XSD: | CONTENTS OF SAMPLE WSDL/XSD: | ||||
@@ -1,5 +1,5 @@ | |||||
#! /usr/bin/env python | #! /usr/bin/env python | ||||
"""wsdl2python and wstools.WSDLTools.WSDLReader tests directory.""" | |||||
"""wstools.WSDLTools.WSDLReader tests directory.""" | |||||
import utils | import utils | ||||
@@ -6,8 +6,10 @@ | |||||
########################################################################### | ########################################################################### | ||||
import sys, unittest | import sys, unittest | ||||
import ConfigParser | |||||
from ZSI.wstools.Utility import DOM | from ZSI.wstools.Utility import DOM | ||||
import utils | |||||
from ZSI.wstools.WSDLTools import WSDLReader | |||||
from ZSI.wstools.TimeoutSocket import TimeoutError | |||||
class WSDLToolsTestCase(unittest.TestCase): | class WSDLToolsTestCase(unittest.TestCase): | ||||
@@ -15,10 +17,7 @@ class WSDLToolsTestCase(unittest.TestCase): | |||||
unittest.TestCase.__init__(self, methodName) | unittest.TestCase.__init__(self, methodName) | ||||
def setUp(self): | def setUp(self): | ||||
global configLoader | |||||
# not thread safe | |||||
self.path = configLoader.nameGenerator.next() | |||||
self.path = nameGenerator.next() | |||||
print self.path | print self.path | ||||
sys.stdout.flush() | sys.stdout.flush() | ||||
@@ -45,9 +44,17 @@ class WSDLToolsTestCase(unittest.TestCase): | |||||
name = DOM.getAttr(cnode, key) | name = DOM.getAttr(cnode, key) | ||||
component[name] | component[name] | ||||
def wsdlTestAll(self): | |||||
def test_all(self): | |||||
try: | try: | ||||
self.wsdl = utils.setUpWsdl(self.path) | |||||
if self.path[:7] == 'http://': | |||||
self.wsdl = WSDLReader().loadFromURL(self.path) | |||||
else: | |||||
self.wsdl = WSDLReader().loadFromFile(self.path) | |||||
except TimeoutError: | |||||
print "connection timed out" | |||||
sys.stdout.flush() | |||||
return | |||||
except: | except: | ||||
self.path = self.path + ": load failed, unable to start" | self.path = self.path + ": load failed, unable to start" | ||||
raise | raise | ||||
@@ -120,25 +127,34 @@ class WSDLToolsTestCase(unittest.TestCase): | |||||
self.checkXSDCollection('simpleType', schema.types, node) | self.checkXSDCollection('simpleType', schema.types, node) | ||||
def makeTestSuite(section=None): | |||||
global configLoader | |||||
def setUpOptions(section): | |||||
cp = ConfigParser.ConfigParser() | |||||
cp.read('config.txt') | |||||
if not cp.sections(): | |||||
print 'fatal error: configuration file config.txt not present' | |||||
sys.exit(0) | |||||
if not cp.has_section(section): | |||||
print '%s section not present in configuration file, exiting' % section | |||||
sys.exit(0) | |||||
return cp, len(cp.options(section)) | |||||
def getOption(cp, section): | |||||
for name, value in cp.items(section): | |||||
yield value | |||||
def makeTestSuite(section='services_by_file'): | |||||
global nameGenerator | |||||
cp, numTests = setUpOptions(section) | |||||
nameGenerator = getOption(cp, section) | |||||
suite = unittest.TestSuite() | suite = unittest.TestSuite() | ||||
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)) | |||||
for i in range(0, numTests): | |||||
suite.addTest(unittest.makeSuite(WSDLToolsTestCase, 'test_')) | |||||
return suite | return suite | ||||
def main(): | def main(): | ||||
loader = utils.MatchTestLoader(False, None, "makeTestSuite") | |||||
unittest.main(defaultTest="makeTestSuite", testLoader=loader) | |||||
unittest.main(defaultTest="makeTestSuite") | |||||
if __name__ == "__main__" : main() | if __name__ == "__main__" : main() |
@@ -7,11 +7,10 @@ | |||||
import unittest, tarfile, os, ConfigParser | import unittest, tarfile, os, ConfigParser | ||||
import test_wsdl | import test_wsdl | ||||
import utils | |||||
SECTION='files' | SECTION='files' | ||||
CONFIG_FILE = 'config.py' | |||||
CONFIG_FILE = 'config.txt' | |||||
def extractFiles(section, option): | def extractFiles(section, option): | ||||
config = ConfigParser.ConfigParser() | config = ConfigParser.ConfigParser() | ||||
@@ -31,8 +30,7 @@ def makeTestSuite(): | |||||
def main(): | def main(): | ||||
extractFiles(SECTION, 'archives') | extractFiles(SECTION, 'archives') | ||||
loader = utils.MatchTestLoader(True, None, "makeTestSuite") | |||||
unittest.main(defaultTest="makeTestSuite", testLoader=loader) | |||||
unittest.main(defaultTest="makeTestSuite") | |||||
if __name__ == "__main__" : main() | if __name__ == "__main__" : main() | ||||
@@ -6,16 +6,14 @@ | |||||
########################################################################### | ########################################################################### | ||||
import unittest | import unittest | ||||
import test_wsdl | import test_wsdl | ||||
import utils | |||||
def makeTestSuite(): | def makeTestSuite(): | ||||
suite = unittest.TestSuite() | suite = unittest.TestSuite() | ||||
suite.addTest(test_wsdl.makeTestSuite(("no_schemas", "simpleTypes", "services_by_http"))) | |||||
suite.addTest(test_wsdl.makeTestSuite("services_by_http")) | |||||
return suite | return suite | ||||
def main(): | def main(): | ||||
loader = utils.MatchTestLoader(True, None, "makeTestSuite") | |||||
unittest.main(defaultTest="makeTestSuite", testLoader=loader) | |||||
unittest.main(defaultTest="makeTestSuite") | |||||
if __name__ == "__main__" : main() | if __name__ == "__main__" : main() | ||||