00001
00002
00003
00004
00005
00006
00007
00008
00009 import sys, unittest
00010 from ServiceTest import main, ServiceTestCase, ServiceTestSuite, TestException
00011
00012 """
00013 Unittest for contacting the SquareService rpc/literal tests.
00014
00015 From the paper "Interoperable WSDL/SOAP web services introduction:
00016 Python ZSI, Excel XP, gSOAP C/C++ & Applix SS", Holger Joukl
00017
00018 WSDL: SquareService.wsdl
00019
00020 """
00021
00022 def dispatch():
00023 """Run all dispatch tests"""
00024 suite = ServiceTestSuite()
00025 suite.addTest(unittest.makeSuite(Test, 'test_dispatch'))
00026 return suite
00027
00028 def local():
00029 """Run all local tests"""
00030 suite = ServiceTestSuite()
00031 suite.addTest(unittest.makeSuite(Test, 'test_local'))
00032 return suite
00033
00034 def net():
00035 """Run all network tests"""
00036 suite = ServiceTestSuite()
00037 suite.addTest(unittest.makeSuite(Test, 'test_net'))
00038 return suite
00039
00040 def all():
00041 """Run all tests"""
00042 suite = ServiceTestSuite()
00043 suite.addTest(unittest.makeSuite(Test, 'test_'))
00044 return suite
00045
00046
00047 class Test(ServiceTestCase):
00048 """Test case for Holger's SquareService
00049 """
00050 name = "test_SquareService"
00051 client_file_name = "SquareService_client.py"
00052 types_file_name = "SquareService_types.py"
00053 server_file_name = "SquareService_server.py"
00054
00055 def __init__(self, methodName):
00056 ServiceTestCase.__init__(self, methodName)
00057 self.wsdl2py_args.append('-b')
00058
00059 def test_local_getSquare(self):
00060 from ZSI.writer import SoapWriter
00061
00062 def test_dispatch_getSquare(self):
00063 loc = self.client_module.SquareServiceLocator()
00064 port = loc.getSquarePort(**self.getPortKWArgs())
00065
00066 msg = self.client_module.getSquareRequest()
00067 msg.X = 4.0
00068 rsp = port.getSquare(msg)
00069
00070 self.failUnless(rsp.Return == msg.X**2,
00071 "Square Failed: got %d, expecting %d" %(rsp.Return,msg.X**2))
00072
00073
00074 if __name__ == "__main__" :
00075 main()