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

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

00001 #!/usr/bin/env python
00002 ############################################################################
00003 # Joshua R. Boverhof, LBNL
00004 # See LBNLCopyright for copyright notice!
00005 ###########################################################################
00006 import os, sys, unittest
00007 from ServiceTest import main, ServiceTestCase, ServiceTestSuite
00008 from ZSI import FaultException, ParsedSoap, SoapWriter
00009 """
00010 Unittest 
00011 
00012 WSDL:   
00013 """
00014 
00015 # General targets
00016 def dispatch():
00017     """Run all dispatch tests"""
00018     suite = ServiceTestSuite()
00019     suite.addTest(unittest.makeSuite(TestCase, 'test_dispatch'))
00020     return suite
00021 
00022 def local():
00023     """Run all local tests"""
00024     suite = ServiceTestSuite()
00025     suite.addTest(unittest.makeSuite(TestCase, 'test_local'))
00026     return suite
00027 
00028 def net():
00029     """Run all network tests"""
00030     suite = ServiceTestSuite()
00031     suite.addTest(unittest.makeSuite(TestCase, 'test_net'))
00032     return suite
00033     
00034 def all():
00035     """Run all tests"""
00036     suite = ServiceTestSuite()
00037     suite.addTest(unittest.makeSuite(TestCase, 'test_'))
00038     return suite
00039 
00040 
00041 class TestCase(ServiceTestCase):
00042     name = "test_Racing"
00043     client_file_name = "Racing_client.py"
00044     types_file_name  = "Racing_types.py"
00045     server_file_name = "Racing_server.py"
00046 
00047     def __init__(self, methodName):
00048         ServiceTestCase.__init__(self, methodName)
00049         self.wsdl2py_args.append('-b')
00050 
00051     def test_local_anyType(self):
00052         """rpc/lit, testing if <any/> lax content handling
00053         should get back dicts and strings 
00054         """
00055         ps = ParsedSoap(MSG)
00056         pyobj = ps.Parse(self.client_module.EventApproximatesSoapOut.typecode)
00057 
00058         any = {'PoolTotals': {'Pool': {'Total': u'4117.66', 'ENumbers': None, 'JackpotNet': None}}, 'Approximates': {'Pool': {'Win': u'3.90,0.00,10.40,11.80,4.70,29.50,29.90,2.40,19.80,0.00', 'Place': u'1.04,0.00,2.80,5.90,2.00,5.20,7.40,1.04,4.00,0.00'}}}
00059 
00060         self.failUnless(pyobj.EventApproximatesResult.Any == any, 'Failed match:\n %s\n\n%s' %(
00061             pyobj.EventApproximatesResult.Any, any))
00062 
00063 
00064         pyobj.EventApproximatesResult.Any = dict(pyobj.EventApproximatesResult.Any)
00065         sw = SoapWriter()
00066         sw.serialize(pyobj)
00067         print str(sw)
00068         ps2 = ParsedSoap(str(sw))
00069         pyobj2 = ps.Parse(self.client_module.EventApproximatesSoapOut.typecode)
00070         print "EAR: ", pyobj2.EventApproximatesResult
00071         print "Any: ", pyobj2.EventApproximatesResult.Any
00072         
00073         
00074         self.failUnless(pyobj.EventApproximatesResult.Any == pyobj2.EventApproximatesResult.Any,
00075             'Failed match:\n %s\n\n%s' %(pyobj.EventApproximatesResult.Any, pyobj2.EventApproximatesResult.Any))
00076 
00077 
00078 
00079 MSG="""<?xml version="1.0" encoding="utf-8"?>
00080 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
00081            <soap:Body>
00082                       <EventApproximatesResponse xmlns="http://direct.tab.com.au/LiveOdds/">
00083                                  <EventApproximatesResult>
00084                                             <Information xmlns="" Jurisdiction="NSW">
00085                                                        <Approximates RID="SG_20070123_05" Timestamp="20:17:17 20070123">
00086                                                                   <Pool>
00087                                                                              <Win>3.90,0.00,10.40,11.80,4.70,29.50,29.90,2.40,19.80,0.00</Win>
00088                                                                              <Place status="">1.04,0.00,2.80,5.90,2.00,5.20,7.40,1.04,4.00,0.00</Place>
00089                                                                   </Pool>
00090                                                        </Approximates>
00091                                                        <PoolTotals RID="SG_20070123_05">
00092                                                                   <Pool BetTypeDesc="Exacta">
00093                                                                              <Total>451.00</Total>
00094                                                                              <ENumbers/>
00095                                                                              <JackpotNet/>
00096                                                                   </Pool>
00097                                                                   <Pool BetTypeDesc="First Four">
00098                                                                              <Total>1001.00</Total>
00099                                                                              <ENumbers/>
00100                                                                              <JackpotNet/>
00101                                                                   </Pool>
00102                                                                   <Pool BetTypeDesc="Place">
00103                                                                              <Total>1750.59</Total>
00104                                                                              <ENumbers/>
00105                                                                              <JackpotNet/>
00106                                                                   </Pool>
00107                                                                   <Pool BetTypeDesc="Quaddie">
00108                                                                              <Total>6052.50</Total>
00109                                                                              <ENumbers>05 06 07 08</ENumbers>
00110                                                                              <JackpotNet/>
00111                                                                   </Pool>
00112                                                                   <Pool BetTypeDesc="Quinella">
00113                                                                              <Total>865.00</Total>
00114                                                                              <ENumbers/>
00115                                                                              <JackpotNet/>
00116                                                                   </Pool>
00117                                                                   <Pool BetTypeDesc="Running Double">
00118                                                                              <Total>21.50</Total>
00119                                                                              <ENumbers/>
00120                                                                              <JackpotNet/>
00121                                                                   </Pool>
00122                                                                   <Pool BetTypeDesc="Trifecta">
00123                                                                              <Total>2575.50</Total>
00124                                                                              <ENumbers/>
00125                                                                              <JackpotNet/>
00126                                                                   </Pool>
00127                                                                   <Pool BetTypeDesc="Win">
00128                                                                              <Total>4117.66</Total>
00129                                                                              <ENumbers/>
00130                                                                              <JackpotNet/>
00131                                                                   </Pool>
00132                                                        </PoolTotals>
00133                                             </Information>
00134                                  </EventApproximatesResult>
00135                       </EventApproximatesResponse>
00136            </soap:Body>
00137 </soap:Envelope>"""
00138 
00139 
00140 if __name__ == "__main__" :
00141     main()

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