Example #1
0
    def test_local_type_substitution2(self):
        """test extension of extension"""

        attr1 = 'aone'
        attr2 = 'atwo'
        attr3 = 'athree'
        self.types_module
        pyobj = GED('urn:test', 'test').pyclass()

        # [ 1489129 ] Unexpected subsitution error message
        #  try to parse before type ever initialized
        """
        ps = ParsedSoap(MSG1)
        pyobj0 = ps.Parse(pyobj.typecode)
        sub0 = pyobj0.Actor
        self.failUnless(sub0.get_attribute_attr1() == attr1, 'bad attribute1')
        self.failUnless(sub0.get_attribute_attr2() == attr2, 'bad attribute2')
        """

        # [ 1489090 ] Derived type attributes don't populate the attr dictionary
        # [ 1489677 ] Derivation from derived type missing derived element
        #
        pyobj.Actor = sub1 = GTD('urn:test', 'TopActor')(None).pyclass()
        sub1.Element1 = 'one'
        sub1.Element2 = 'two'
        sub1.Element3 = 'three'
        sub1.set_attribute_attr1(attr1)
        sub1.set_attribute_attr2(attr2)
        sub1.set_attribute_attr3(attr3)

        sw = SoapWriter()
        sw.serialize(pyobj)
        xml = str(sw)
        ps = ParsedSoap(xml)
        pyobj2 = ps.Parse(pyobj.typecode)
        sub2 = pyobj2.Actor

        self.failUnless(sub2.get_attribute_attr1() == attr1, 'bad attribute 1')
        self.failUnless(sub2.get_attribute_attr2() == attr2, 'bad attribute 2')
        self.failUnless(sub2.get_attribute_attr3() == attr3, 'bad attribute 3')

        self.failUnless(sub2.Element1 == sub1.Element1, 'bad element 1')
        self.failUnless(sub2.Element2 == sub1.Element2, 'bad element 2')
        self.failUnless(sub2.Element3 == sub1.Element3, 'bad element 3')

        # check parsed out correct type
        self.failUnless(
            isinstance(sub2.typecode, sub1.typecode.__class__),
            'local element actor "%s" must be an instance of "%s"' %
            (sub2.typecode, sub1.typecode.__class__))

        # check local element is derived from base
        base = GTD('urn:test', 'BaseActor')
        self.failUnless(
            isinstance(sub2.typecode, base),
            'local element actor must be a derived type of "%s"' % base)
Example #2
0
    def test_local_type_substitution_test2(self):
        """test extension of extension"""

        attr1 = 'aone'
        attr2 = 'atwo'
        attr3 = 'athree'
        self.types_module
        pyobj = GED('urn:test', 'test2').pyclass()

        # Test maxOccurs>1 for substitution
        #
        pyobj.Actor = [GTD('urn:test', 'TopActor')(None).pyclass()]
        sub1 = pyobj.Actor[0]
        sub1.Element1 = 'one'
        sub1.Element2 = 'two'
        sub1.Element3 = 'three'
        sub1.set_attribute_attr1(attr1)
        sub1.set_attribute_attr2(attr2)
        sub1.set_attribute_attr3(attr3)

        sw = SoapWriter()
        sw.serialize(pyobj)
        xml = str(sw)
        ps = ParsedSoap(xml)
        pyobj2 = ps.Parse(pyobj.typecode)
        sub2 = pyobj2.Actor[0]

        self.failUnless(sub2.get_attribute_attr1() == attr1, 'bad attribute 1')
        self.failUnless(sub2.get_attribute_attr2() == attr2, 'bad attribute 2')
        self.failUnless(sub2.get_attribute_attr3() == attr3, 'bad attribute 3')

        self.failUnless(sub2.Element1 == sub1.Element1, 'bad element 1')
        self.failUnless(sub2.Element2 == sub1.Element2, 'bad element 2')
        self.failUnless(sub2.Element3 == sub1.Element3, 'bad element 3')

        # check parsed out correct type
        self.failUnless(
            isinstance(sub2.typecode, sub1.typecode.__class__),
            'local element actor "%s" must be an instance of "%s"' %
            (sub2.typecode, sub1.typecode.__class__))

        # check local element is derived from base
        base = GTD('urn:test', 'BaseActor')
        self.failUnless(
            isinstance(sub2.typecode, base),
            'local element actor must be a derived type of "%s"' % base)
Example #3
0
    def test_local_type_substitution1(self):
        """test extension.   Parse known instance, serialize an equivalent, Parse it back. """
        attr1 = 'myclass'
        attr2 = 'whatever'
        self.types_module
        pyobj = GED('urn:test', 'test').pyclass()

        # [ 1489129 ] Unexpected subsitution error message
        #  try to parse before type ever initialized
        ps = ParsedSoap(MSG1)
        pyobj0 = ps.Parse(pyobj.typecode)
        sub0 = pyobj0.Actor
        self.failUnless(sub0.get_attribute_attr1() == attr1, 'bad attribute1')
        self.failUnless(sub0.get_attribute_attr2() == attr2, 'bad attribute2')

        # [ 1489090 ] Derived type attributes don't populate the attr dictionary
        #
        pyobj.Actor = sub1 = GTD('urn:test', 'MiddleActor')(None).pyclass()
        sub1.Element1 = 'foo'
        sub1.Element2 = 'bar'
        sub1.set_attribute_attr1(attr1)
        sub1.set_attribute_attr2(attr2)

        sw = SoapWriter()
        sw.serialize(pyobj)
        xml = str(sw)
        ps = ParsedSoap(xml)
        pyobj2 = ps.Parse(pyobj.typecode)
        sub2 = pyobj2.Actor

        self.failUnless(sub2.get_attribute_attr1() == attr1,
                        'bad attribute class')
        self.failUnless(sub2.get_attribute_attr2() == attr2,
                        'bad attribute name')

        # check parsed out correct type
        self.failUnless(
            isinstance(sub2.typecode, sub1.typecode.__class__),
            'local element actor "%s" must be an instance of "%s"' %
            (sub2.typecode, sub1.typecode.__class__))

        # check local element is derived from base
        base = GTD('urn:test', 'BaseActor')
        self.failUnless(
            isinstance(sub2.typecode, base),
            'local element actor must be a derived type of "%s"' % base)
 def __init__(self, pname, ofwhat=(), attributes=None, extend=False, restrict=False, **kw):
     #ns = ns0.return_document_revision_Def.schema
     TClist = [GTD("http://www.sugarcrm.com/sugarcrm","document_revision",lazy=False)(pname="document_revision", aname="_document_revision", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("http://www.sugarcrm.com/sugarcrm","error_value",lazy=False)(pname="error", aname="_error", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))]
     self.attribute_typecode_dict = attributes or {}
     if extend: TClist += ofwhat
     if restrict: TClist = ofwhat
     ZSI.TCcompound.ComplexType.__init__(self, None, TClist, pname=pname, inorder=0, **kw)
     class Holder:
         __metaclass__ = pyclass_type
         typecode = self
         def __init__(self):
             # pyclass
             self._document_revision = None
             self._error = None
             return
     Holder.__name__ = "return_document_revision_Holder"
     self.pyclass = Holder
 def __init__(self, pname, ofwhat=(), attributes=None, extend=False, restrict=False, **kw):
     #ns = ns0.get_quick_sync_result_encoded_Def.schema
     TClist = [ZSI.TC.String(pname="result", aname="_result", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.Iint(pname="result_count", aname="_result_count", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.Iint(pname="next_offset", aname="_next_offset", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.Iint(pname="total_count", aname="_total_count", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("http://www.sugarcrm.com/sugarcrm","error_value",lazy=False)(pname="error", aname="_error", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))]
     self.attribute_typecode_dict = attributes or {}
     if extend: TClist += ofwhat
     if restrict: TClist = ofwhat
     ZSI.TCcompound.ComplexType.__init__(self, None, TClist, pname=pname, inorder=0, **kw)
     class Holder:
         __metaclass__ = pyclass_type
         typecode = self
         def __init__(self):
             # pyclass
             self._result = None
             self._result_count = None
             self._next_offset = None
             self._total_count = None
             self._error = None
             return
     Holder.__name__ = "get_quick_sync_result_encoded_Holder"
     self.pyclass = Holder
 def __init__(self, pname, ofwhat=(), attributes=None, extend=False, restrict=False, **kw):
     #ns = ns0.set_relationship_list_result_Def.schema
     TClist = [ZSI.TCnumbers.Iint(pname="created", aname="_created", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TCnumbers.Iint(pname="failed", aname="_failed", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("http://www.sugarcrm.com/sugarcrm","error_value",lazy=False)(pname="error", aname="_error", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))]
     self.attribute_typecode_dict = attributes or {}
     if extend: TClist += ofwhat
     if restrict: TClist = ofwhat
     ZSI.TCcompound.ComplexType.__init__(self, None, TClist, pname=pname, inorder=0, **kw)
     class Holder:
         __metaclass__ = pyclass_type
         typecode = self
         def __init__(self):
             # pyclass
             self._created = None
             self._failed = None
             self._error = None
             return
     Holder.__name__ = "set_relationship_list_result_Holder"
     self.pyclass = Holder
 def __init__(self, pname, ofwhat=(), attributes=None, extend=False, restrict=False, **kw):
     #ns = ns0.entry_value_Def.schema
     TClist = [ZSI.TC.String(pname="id", aname="_id", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname="module_name", aname="_module_name", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), GTD("http://www.sugarcrm.com/sugarcrm","name_value_list",lazy=False)(pname="name_value_list", aname="_name_value_list", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))]
     self.attribute_typecode_dict = attributes or {}
     if extend: TClist += ofwhat
     if restrict: TClist = ofwhat
     ZSI.TCcompound.ComplexType.__init__(self, None, TClist, pname=pname, inorder=0, **kw)
     class Holder:
         __metaclass__ = pyclass_type
         typecode = self
         def __init__(self):
             # pyclass
             self._id = None
             self._module_name = None
             self._name_value_list = None
             return
     Holder.__name__ = "entry_value_Holder"
     self.pyclass = Holder