当前位置: 首页>>代码示例>>Python>>正文


Python utils.DummyTransport类代码示例

本文整理汇总了Python中tests.utils.DummyTransport的典型用法代码示例。如果您正苦于以下问题:Python DummyTransport类的具体用法?Python DummyTransport怎么用?Python DummyTransport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DummyTransport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_multiple_only_target_ns

def test_multiple_only_target_ns():
    node_a = etree.fromstring("""
        <?xml version="1.0"?>
        <xsd:schema
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/a"
            targetNamespace="http://tests.python-zeep.org/a"
            elementFormDefault="qualified">

          <xsd:import schemaLocation="http://tests.python-zeep.org/b.xsd"/>
          <xsd:import schemaLocation="http://tests.python-zeep.org/c.xsd"/>
        </xsd:schema>
    """.strip())

    node_b = etree.fromstring("""
        <?xml version="1.0"?>
        <xsd:schema
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified"
            targetNamespace="http://tests.python-zeep.org/duplicate-ns">
        </xsd:schema>
    """.strip())

    transport = DummyTransport()
    transport.bind('http://tests.python-zeep.org/b.xsd', node_b)
    transport.bind('http://tests.python-zeep.org/c.xsd', node_b)
    with pytest.warns(ZeepWarning):
        xsd.Schema(node_a, transport=transport)
开发者ID:josemlp91,项目名称:python-zeep,代码行数:28,代码来源:test_xsd_schemas.py

示例2: test_soap_array_parse_remote_ns

def test_soap_array_parse_remote_ns():
    transport = DummyTransport()
    transport.bind(
        'http://schemas.xmlsoap.org/soap/encoding/',
        load_xml(io.open('tests/wsdl_files/soap-enc.xsd', 'r').read().encode('utf-8')))

    schema = xsd.Schema(load_xml("""
        <?xml version="1.0"?>
        <xsd:schema
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          xmlns:tns="http://tests.python-zeep.org/"
          xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          targetNamespace="http://tests.python-zeep.org/"
          elementFormDefault="qualified">
          <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
          <xsd:simpleType name="CountryCodeType">
            <xsd:restriction base="xsd:string">
              <xsd:length value="2"/>
              <xsd:pattern value="[a-zA-Z]{2}"/>
            </xsd:restriction>
          </xsd:simpleType>
          <xsd:complexType name="CountryItemType">
            <xsd:sequence>
              <xsd:element name="code" type="tns:CountryCodeType"/>
              <xsd:element name="name" type="xsd:string"/>
            </xsd:sequence>
          </xsd:complexType>
          <xsd:complexType name="CountriesArrayType">
            <xsd:complexContent>
              <xsd:restriction base="soapenc:Array">
                <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="tns:CountryItemType[]"/>
              </xsd:restriction>
            </xsd:complexContent>
          </xsd:complexType>
          <xsd:element name="countries" type="tns:CountriesArrayType"/>
        </xsd:schema>
    """), transport)

    doc = load_xml("""
      <countries
            SOAP-ENC:arrayType="ns1:CountryItemType[1]"
            xsi:type="ns1:CountriesArrayType"
            xmlns:ns1="http://tests.python-zeep.org/"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <item xsi:type="ns1:CountryItemType">
          <code xsi:type="ns1:CountryCodeType">NL</code>
          <name xsi:type="xsd:string">The Netherlands</name>
        </item>
      </countries>
    """)

    elm = schema.get_element('ns0:countries')
    data = elm.parse(doc, schema)

    assert data[0].code == 'NL'
    assert data[0].name == 'The Netherlands'
开发者ID:ovnicraft,项目名称:python-zeep,代码行数:60,代码来源:test_wsdl_arrays.py

示例3: test_no_target_namespace

def test_no_target_namespace():
    node_a = etree.fromstring("""
        <?xml version="1.0"?>
        <xsd:schema
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/a"
            targetNamespace="http://tests.python-zeep.org/a"
            elementFormDefault="qualified">

          <xsd:import schemaLocation="http://tests.python-zeep.org/b.xsd"/>

          <xsd:element name="container">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element ref="bla"/>
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>

        </xsd:schema>
    """.strip())

    node_b = etree.fromstring("""
        <?xml version="1.0"?>
        <xsd:schema
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified">
            <xsd:element name="bla" type="xsd:string"/>
        </xsd:schema>
    """.strip())

    transport = DummyTransport()
    transport.bind('http://tests.python-zeep.org/b.xsd', node_b)
    xsd.Schema(node_a, transport=transport)
开发者ID:josemlp91,项目名称:python-zeep,代码行数:34,代码来源:test_xsd_schemas.py

示例4: test_xml_namespace

def test_xml_namespace():
    xmlns = load_xml("""
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:xml="http://www.w3.org/XML/1998/namespace"
            targetNamespace="http://www.w3.org/XML/1998/namespace"
            elementFormDefault="qualified">
          <xs:attribute name="lang" type="xs:string"/>
        </xs:schema>
    """)

    transport = DummyTransport()
    transport.bind('http://www.w3.org/2001/xml.xsd', xmlns)

    xsd.Schema(load_xml("""
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/"
            targetNamespace="http://tests.python-zeep.org/"
            elementFormDefault="qualified">
          <xs:import namespace="http://www.w3.org/XML/1998/namespace"
                     schemaLocation="http://www.w3.org/2001/xml.xsd"/>
          <xs:element name="container">
            <xs:complexType>
              <xs:sequence/>
              <xs:attribute ref="xml:lang"/>
            </xs:complexType>
          </xs:element>
        </xs:schema>
    """), transport=transport)
开发者ID:ovnicraft,项目名称:python-zeep,代码行数:32,代码来源:test_xsd_schemas.py

示例5: test_include_recursion

def test_include_recursion():
    node_a = etree.fromstring(
        """
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/a"
            targetNamespace="http://tests.python-zeep.org/a"
            xmlns:b="http://tests.python-zeep.org/b"
            elementFormDefault="qualified">

            <xs:import
                schemaLocation="http://tests.python-zeep.org/b.xsd"
                namespace="http://tests.python-zeep.org/b"/>

        </xs:schema>
    """.strip()
    )

    node_b = etree.fromstring(
        """
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/b"
            targetNamespace="http://tests.python-zeep.org/b"
            elementFormDefault="qualified">

            <xs:include schemaLocation="http://tests.python-zeep.org/c.xsd"/>
            <xs:element name="bar" type="xs:string"/>
        </xs:schema>
    """.strip()
    )

    node_c = etree.fromstring(
        """
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/b"
            targetNamespace="http://tests.python-zeep.org/b"
            elementFormDefault="qualified">

            <xs:include schemaLocation="http://tests.python-zeep.org/b.xsd"/>

            <xs:element name="foo" type="xs:string"/>
        </xs:schema>
    """.strip()
    )

    transport = DummyTransport()
    transport.bind("http://tests.python-zeep.org/b.xsd", node_b)
    transport.bind("http://tests.python-zeep.org/c.xsd", node_c)

    schema = xsd.Schema(node_a, transport=transport)
    schema.get_element("{http://tests.python-zeep.org/b}foo")
    schema.get_element("{http://tests.python-zeep.org/b}bar")
开发者ID:mvantellingen,项目名称:python-zeep,代码行数:57,代码来源:test_xsd_schemas.py

示例6: test_cyclic_imports

def test_cyclic_imports():
    schema_a = etree.fromstring(
        """
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/a"
            targetNamespace="http://tests.python-zeep.org/a"
            xmlns:b="http://tests.python-zeep.org/b"
            elementFormDefault="qualified">

            <xs:import
                schemaLocation="http://tests.python-zeep.org/b.xsd"
                namespace="http://tests.python-zeep.org/b"/>
        </xs:schema>
    """.strip()
    )

    schema_b = etree.fromstring(
        """
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/b"
            targetNamespace="http://tests.python-zeep.org/b"
            xmlns:c="http://tests.python-zeep.org/c"
            elementFormDefault="qualified">

            <xs:import
                schemaLocation="http://tests.python-zeep.org/c.xsd"
                namespace="http://tests.python-zeep.org/c"/>
        </xs:schema>
    """.strip()
    )

    schema_c = etree.fromstring(
        """
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/c"
            targetNamespace="http://tests.python-zeep.org/c"
            elementFormDefault="qualified">

            <xs:import
                schemaLocation="http://tests.python-zeep.org/a.xsd"
                namespace="http://tests.python-zeep.org/a"/>
        </xs:schema>
    """.strip()
    )

    transport = DummyTransport()
    transport.bind("http://tests.python-zeep.org/a.xsd", schema_a)
    transport.bind("http://tests.python-zeep.org/b.xsd", schema_b)
    transport.bind("http://tests.python-zeep.org/c.xsd", schema_c)
    xsd.Schema(schema_a, transport=transport, location="http://tests.python-zeep.org/a.xsd")
开发者ID:mvantellingen,项目名称:python-zeep,代码行数:56,代码来源:test_xsd_schemas.py

示例7: test_wsdl_array_type

def test_wsdl_array_type():
    transport = DummyTransport()
    transport.bind(
        'http://schemas.xmlsoap.org/soap/encoding/',
        load_xml(io.open('tests/wsdl_files/soap-enc.xsd', 'r').read().encode('utf-8')))

    schema = xsd.Schema(load_xml("""
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                    xmlns:tns="http://tests.python-zeep.org/"
                    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
                    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                    targetNamespace="http://tests.python-zeep.org/"
                    elementFormDefault="qualified">
          <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
          <xsd:complexType name="array">
            <xsd:complexContent>
              <xsd:restriction base="SOAP-ENC:Array">
                <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:base[]"/>
              </xsd:restriction>
            </xsd:complexContent>
          </xsd:complexType>
          <xsd:complexType name="base">
            <xsd:sequence>
              <xsd:element minOccurs="0" name="item_1" type="xsd:string"/>
              <xsd:element minOccurs="0" name="item_2" type="xsd:string"/>
            </xsd:sequence>
          </xsd:complexType>
          <xsd:element name="array" type="tns:array"/>
        </xsd:schema>
    """), transport)
    array_elm = schema.get_element('{http://tests.python-zeep.org/}array')

    item_type = schema.get_type('{http://tests.python-zeep.org/}base')
    item_1 = item_type(item_1='foo_1', item_2='bar_1')
    item_2 = item_type(item_1='foo_2', item_2='bar_2')

    array = array_elm([
        xsd.AnyObject(item_type, item_1),
        xsd.AnyObject(item_type, item_2),
    ])

    node = etree.Element('document')
    array_elm.render(node, array)
    expected = """
        <document>
            <ns0:array xmlns:ns0="http://tests.python-zeep.org/">
                <ns0:item_1>foo_1</ns0:item_1>
                <ns0:item_2>bar_1</ns0:item_2>
                <ns0:item_1>foo_2</ns0:item_1>
                <ns0:item_2>bar_2</ns0:item_2>
            </ns0:array>
        </document>
    """
    assert_nodes_equal(expected, node)
开发者ID:pavelbrych,项目名称:python-zeep,代码行数:54,代码来源:test_xsd_integration.py

示例8: test_create_import_schema

def test_create_import_schema(recwarn):
    content = StringIO("""
    <?xml version="1.0"?>
    <wsdl:definitions
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/">

      <wsdl:types>
        <xsd:schema>
          <xsd:import namespace="http://tests.python-zeep.org/a"
                      schemaLocation="a.xsd"/>
        </xsd:schema>
        <xsd:schema>
          <xsd:import namespace="http://tests.python-zeep.org/b"
                      schemaLocation="b.xsd"/>
        </xsd:schema>
      </wsdl:types>
    </wsdl:definitions>
    """.strip())

    schema_node_a = etree.fromstring("""
        <?xml version="1.0"?>
        <xsd:schema
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/a"
            targetNamespace="http://tests.python-zeep.org/a"
            xmlns:b="http://tests.python-zeep.org/b"
            elementFormDefault="qualified">
        </xsd:schema>
    """.strip())

    schema_node_b = etree.fromstring("""
        <?xml version="1.0"?>
        <xsd:schema
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/b"
            targetNamespace="http://tests.python-zeep.org/b"
            elementFormDefault="qualified">

            <xsd:element name="global" type="xsd:string"/>
        </xsd:schema>
    """.strip())

    transport = DummyTransport()
    transport.bind('http://tests.python-zeep.org/a.xsd', schema_node_a)
    transport.bind('http://tests.python-zeep.org/b.xsd', schema_node_b)

    document = wsdl.Document(
        content, transport, 'http://tests.python-zeep.org/content.wsdl')

    assert len(recwarn) == 0
    assert document.types.get_element('{http://tests.python-zeep.org/b}global')
开发者ID:tobirl,项目名称:python-zeep,代码行数:53,代码来源:test_wsdl.py

示例9: test_include_different_form_defaults

def test_include_different_form_defaults():
    node_a = etree.fromstring("""
        <?xml version="1.0"?>
        <xs:schema
            xmlns="http://tests.python-zeep.org/"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://tests.python-zeep.org/">

            <xs:include
                schemaLocation="http://tests.python-zeep.org/b.xsd"/>
        </xs:schema>
    """.strip())

    # include without default namespace, other xsd prefix
    node_b = load_xml("""
        <?xml version="1.0"?>
        <xsd:schema
            elementFormDefault="qualified"
            attributeFormDefault="qualified"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/b">

            <xsd:element name="container" type="foo"/>

            <xsd:complexType name="foo">
              <xsd:sequence>
                <xsd:element name="item" type="xsd:string"/>
              </xsd:sequence>
              <xsd:attribute name="attr" type="xsd:string"/>
            </xsd:complexType>
        </xsd:schema>
    """)

    transport = DummyTransport()
    transport.bind('http://tests.python-zeep.org/b.xsd', node_b)

    schema = xsd.Schema(node_a, transport=transport)
    item = schema.get_element('{http://tests.python-zeep.org/}container')
    obj = item(item='foo', attr='bar')
    node = render_node(item, obj)

    expected = load_xml("""
        <document>
          <ns0:container xmlns:ns0="http://tests.python-zeep.org/" ns0:attr="bar">
            <ns0:item>foo</ns0:item>
          </ns0:container>
        </document>
    """)
    assert_nodes_equal(expected, node)
开发者ID:ovnicraft,项目名称:python-zeep,代码行数:49,代码来源:test_xsd_schemas.py

示例10: test_duplicate_target_namespace

def test_duplicate_target_namespace():
    schema_a = etree.fromstring(
        """
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/a"
            targetNamespace="http://tests.python-zeep.org/a"
            elementFormDefault="qualified">

            <xs:import
                schemaLocation="http://tests.python-zeep.org/b.xsd"
                namespace="http://tests.python-zeep.org/duplicate"/>
            <xs:import
                schemaLocation="http://tests.python-zeep.org/c.xsd"
                namespace="http://tests.python-zeep.org/duplicate"/>
        </xs:schema>
    """.strip()
    )

    schema_b = etree.fromstring(
        """
        <?xml version="1.0"?>
        <xsd:schema
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://tests.python-zeep.org/duplicate"
            elementFormDefault="qualified">
        </xsd:schema>
    """.strip()
    )

    schema_c = etree.fromstring(
        """
        <?xml version="1.0"?>
        <xsd:schema
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://tests.python-zeep.org/duplicate"
            elementFormDefault="qualified">
        </xsd:schema>
    """.strip()
    )

    transport = DummyTransport()
    transport.bind("http://tests.python-zeep.org/a.xsd", schema_a)
    transport.bind("http://tests.python-zeep.org/b.xsd", schema_b)
    transport.bind("http://tests.python-zeep.org/c.xsd", schema_c)
    with pytest.warns(ZeepWarning):
        xsd.Schema(schema_a, transport=transport)
开发者ID:mvantellingen,项目名称:python-zeep,代码行数:48,代码来源:test_xsd_schemas.py

示例11: test_wsdl_dtd_entities_rules

def test_wsdl_dtd_entities_rules():
    wsdl_declaration = u"""<!DOCTYPE Author [
        <!ENTITY writer "Donald Duck.">
        ]>
        <wsdl:definitions
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:tns="http://tests.python-zeep.org/xsd-main"
        xmlns:mine="http://tests.python-zeep.org/xsd-secondary"
        xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
        targetNamespace="http://tests.python-zeep.org/xsd-main">
        <wsdl:types>
          <xsd:schema
              targetNamespace="http://tests.python-zeep.org/xsd-main"
              xmlns:tns="http://tests.python-zeep.org/xsd-main">
            <xsd:element name="input" type="xsd:string"/>
          </xsd:schema>
        </wsdl:types>
        <wsdl:message name="message-1">
          <wsdl:part name="response" element="tns:input"/>
        </wsdl:message>
        <wsdl:portType name="TestPortType">
          <wsdl:operation name="TestOperation1">
            <wsdl:input message="message-1"/>
          </wsdl:operation>
        </wsdl:portType>
        </wsdl:definitions>
    """.strip()

    transport = DummyTransport()
    transport.bind('http://tests.python-zeep.org/schema-2.wsdl', wsdl_declaration)

    with pytest.raises(DTDForbidden):
        wsdl.Document(
            StringIO(wsdl_declaration), transport,
            settings=Settings(forbid_dtd=True))

    with pytest.raises(EntitiesForbidden):
        wsdl.Document(StringIO(wsdl_declaration), transport)

    document = wsdl.Document(
        StringIO(wsdl_declaration), transport,
        settings=Settings(forbid_entities=False))
    document.dump()
开发者ID:tobirl,项目名称:python-zeep,代码行数:44,代码来源:test_wsdl.py

示例12: test_auto_import_known_schema

def test_auto_import_known_schema():
    content = io.open('tests/wsdl_files/soap-enc.xsd', 'rb').read()

    transport = DummyTransport()
    transport.bind('http://schemas.xmlsoap.org/soap/encoding/', content)

    schema = xsd.Schema(load_xml("""
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
            xmlns:tns="http://tests.python-zeep.org/"
            targetNamespace="http://tests.python-zeep.org/"
            elementFormDefault="qualified">
          <xs:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
          <xs:group ref="soap-enc:Struct"/>
        </xs:schema>
    """), transport=transport)
    schema.set_ns_prefix('soap-enc', 'http://schemas.xmlsoap.org/soap/encoding/')
    schema.get_group('soap-enc:Struct')
开发者ID:tobirl,项目名称:python-zeep,代码行数:20,代码来源:test_xsd_schemas.py

示例13: test_get_type_through_import

def test_get_type_through_import():
    schema_a = etree.fromstring(
        """
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/a"
            targetNamespace="http://tests.python-zeep.org/a"
            xmlns:b="http://tests.python-zeep.org/b"
            elementFormDefault="qualified">

            <xs:import
                schemaLocation="http://tests.python-zeep.org/b.xsd"
                namespace="http://tests.python-zeep.org/b"/>
            <xs:element name="foo" type="b:bar"/>

        </xs:schema>
    """.strip()
    )

    schema_b = etree.fromstring(
        """
        <?xml version="1.0"?>
        <xs:schema
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/b"
            targetNamespace="http://tests.python-zeep.org/b"
            xmlns:c="http://tests.python-zeep.org/c"
            elementFormDefault="qualified">

            <xs:complexType name="bar"/>

        </xs:schema>
    """.strip()
    )

    transport = DummyTransport()
    transport.bind("http://tests.python-zeep.org/a.xsd", schema_a)
    transport.bind("http://tests.python-zeep.org/b.xsd", schema_b)
    xsd.Schema(schema_a, transport=transport)
开发者ID:mvantellingen,项目名称:python-zeep,代码行数:40,代码来源:test_xsd_schemas.py

示例14: test_include_no_default_namespace

def test_include_no_default_namespace():
    node_a = etree.fromstring("""
        <?xml version="1.0"?>
        <xs:schema
            xmlns="http://tests.python-zeep.org/tns"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://tests.python-zeep.org/tns"
            elementFormDefault="qualified">

            <xs:include
                schemaLocation="http://tests.python-zeep.org/b.xsd"/>

            <xs:element name="container" type="foo"/>
        </xs:schema>
    """.strip())

    # include without default namespace, other xsd prefix
    node_b = etree.fromstring("""
        <?xml version="1.0"?>
        <xsd:schema
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/b">

            <xsd:simpleType name="my-string">
              <xsd:restriction base="xsd:boolean"/>
            </xsd:simpleType>

            <xsd:complexType name="foo">
              <xsd:sequence>
                <xsd:element name="item" type="my-string"/>
              </xsd:sequence>
            </xsd:complexType>
        </xsd:schema>
    """.strip())

    transport = DummyTransport()
    transport.bind('http://tests.python-zeep.org/b.xsd', node_b)
    schema = xsd.Schema(node_a, transport=transport)
    item = schema.get_element('{http://tests.python-zeep.org/tns}container')
    assert item
开发者ID:ovnicraft,项目名称:python-zeep,代码行数:40,代码来源:test_xsd_schemas.py

示例15: test_wsdl_imports_xsd

def test_wsdl_imports_xsd(recwarn):
    content = StringIO("""
    <?xml version="1.0"?>
    <wsdl:definitions
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/">
      <wsdl:import location="a.xsd" namespace="http://tests.python-zeep.org/a"/>
    </wsdl:definitions>
    """.strip())

    schema_node_a = etree.fromstring("""
        <?xml version="1.0"?>
        <xsd:schema
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/a"
            targetNamespace="http://tests.python-zeep.org/a"
            xmlns:b="http://tests.python-zeep.org/b"
            elementFormDefault="qualified">
          <xsd:import namespace="http://tests.python-zeep.org/b" schemaLocation="b.xsd"/>
        </xsd:schema>
    """.strip())

    schema_node_b = etree.fromstring("""
        <?xml version="1.0"?>
        <xsd:schema
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://tests.python-zeep.org/b"
            targetNamespace="http://tests.python-zeep.org/b"
            elementFormDefault="qualified">
        </xsd:schema>
    """.strip())

    transport = DummyTransport()
    transport.bind('http://tests.python-zeep.org/a.xsd', schema_node_a)
    transport.bind('http://tests.python-zeep.org/b.xsd', schema_node_b)

    wsdl.Document(
        content, transport, 'http://tests.python-zeep.org/content.wsdl')
开发者ID:tobirl,项目名称:python-zeep,代码行数:39,代码来源:test_wsdl.py


注:本文中的tests.utils.DummyTransport类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。