test_union.py :  » Web-Services » ZSI » ZSI-2.0 » test » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Web Services » ZSI 
ZSI » ZSI 2.0 » test » test_union.py
#!/usr/bin/env python
import unittest, sys, sha, base64
import ZSI 
from ZSI import _get_element_nsuri_name
from ZSI.schema import GED,TypeDefinition,ElementDeclaration
from ZSI.parse import ParsedSoap
from ZSI.wstools.c14n import Canonicalize
from ZSI.wstools.Namespaces import WSA200403,SOAP
from cStringIO import StringIO


# 
# Generated code
class ns3:
    class localPAssertionId_Dec(ElementDeclaration):
        literal = "localPAssertionId"
        schema = "http://www.pasoa.org/schemas/version024/PStruct.xsd"
        def __init__(self, **kw):
            kw["pname"] = ("http://www.pasoa.org/schemas/version024/PStruct.xsd","localPAssertionId")
            kw["aname"] = "_localPAssertionId"
            if ns3.LocalPAssertionId_Def not in ns3.localPAssertionId_Dec.__bases__:
                bases = list(ns3.localPAssertionId_Dec.__bases__)
                bases.insert(0, ns3.LocalPAssertionId_Def)
                ns3.localPAssertionId_Dec.__bases__ = tuple(bases)

            ns3.LocalPAssertionId_Def.__init__(self, **kw)
            if self.pyclass is not None: self.pyclass.__name__ = "localPAssertionId_Dec_Holder"


    class LocalPAssertionId_Def(ZSI.TC.Union, TypeDefinition):
        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')]
        schema = "http://www.pasoa.org/schemas/version024/PStruct.xsd"
        type = (schema, "LocalPAssertionId")
        def __init__(self, pname, **kw):
            ZSI.TC.Union.__init__(self, pname, **kw)



class UnionTestCase(unittest.TestCase):
    "test Union TypeCode"

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def check_union_long(self):
        import time
        typecode = GED("http://www.pasoa.org/schemas/version024/PStruct.xsd", "localPAssertionId")
        for value in (1234455, "whatever", "urn:whatever"):
            sw = ZSI.SoapWriter()
            sw.serialize(value, typecode)

            xml = str(sw)
            ps = ParsedSoap(xml)
            pyobj = ps.Parse(typecode)

            # Union Limitation:  
            #     currently it tries to parse it sequentially via memberTypes,
            #     so string is going to parse the URI when we want anyURI
            self.failUnless(value == pyobj, 'Expected equivalent')



def makeTestSuite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(UnionTestCase, "check"))
    return suite

def main():
    unittest.main(defaultTest="makeTestSuite")

if __name__ == '__main__': 
    main()

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.