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

contrib/opal/ZSI/test/test_union.py

00001 #!/usr/bin/env python
00002 import unittest, sys, sha, base64
00003 import ZSI 
00004 from ZSI import _get_element_nsuri_name
00005 from ZSI.schema import GED, TypeDefinition, ElementDeclaration
00006 from ZSI.parse import ParsedSoap
00007 from ZSI.wstools.c14n import Canonicalize
00008 from ZSI.wstools.Namespaces import WSA200403, SOAP
00009 from cStringIO import StringIO
00010 
00011 
00012 # 
00013 # Generated code
00014 class ns3:
00015     class localPAssertionId_Dec(ElementDeclaration):
00016         literal = "localPAssertionId"
00017         schema = "http://www.pasoa.org/schemas/version024/PStruct.xsd"
00018         def __init__(self, **kw):
00019             kw["pname"] = ("http://www.pasoa.org/schemas/version024/PStruct.xsd","localPAssertionId")
00020             kw["aname"] = "_localPAssertionId"
00021             if ns3.LocalPAssertionId_Def not in ns3.localPAssertionId_Dec.__bases__:
00022                 bases = list(ns3.localPAssertionId_Dec.__bases__)
00023                 bases.insert(0, ns3.LocalPAssertionId_Def)
00024                 ns3.localPAssertionId_Dec.__bases__ = tuple(bases)
00025 
00026             ns3.LocalPAssertionId_Def.__init__(self, **kw)
00027             if self.pyclass is not None: self.pyclass.__name__ = "localPAssertionId_Dec_Holder"
00028 
00029 
00030     class LocalPAssertionId_Def(ZSI.TC.Union, TypeDefinition):
00031         memberTypes = [(u'http://www.w3.org/2001/XMLSchema', u'long'), (u'http://www.w3.org/2001/XMLSchema', u'string'), (u'http://www.w3.org/2001/XMLSchema', u'anyURI')]
00032         schema = "http://www.pasoa.org/schemas/version024/PStruct.xsd"
00033         type = (schema, "LocalPAssertionId")
00034         def __init__(self, pname, **kw):
00035             ZSI.TC.Union.__init__(self, pname, **kw)
00036 
00037 
00038 
00039 class UnionTestCase(unittest.TestCase):
00040     "test Union TypeCode"
00041 
00042     def setUp(self):
00043         pass
00044 
00045     def tearDown(self):
00046         pass
00047 
00048     def check_union_long(self):
00049         import time
00050         typecode = GED("http://www.pasoa.org/schemas/version024/PStruct.xsd", "localPAssertionId")
00051         for value in (1234455, "whatever", "urn:whatever"):
00052             sw = ZSI.SoapWriter()
00053             sw.serialize(value, typecode)
00054 
00055             xml = str(sw)
00056             ps = ParsedSoap(xml)
00057             pyobj = ps.Parse(typecode)
00058 
00059             # Union Limitation:  
00060             #     currently it tries to parse it sequentially via memberTypes,
00061             #     so string is going to parse the URI when we want anyURI
00062             self.failUnless(value == pyobj, 'Expected equivalent')
00063 
00064 
00065 
00066 def makeTestSuite():
00067     suite = unittest.TestSuite()
00068     suite.addTest(unittest.makeSuite(UnionTestCase, "check"))
00069     return suite
00070 
00071 def main():
00072     unittest.main(defaultTest="makeTestSuite")
00073 
00074 if __name__ == '__main__': 
00075     main()
00076 

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