How to use zeep - 10 common examples

To help you get started, we’ve selected a few zeep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_choice():
    xsd_type = xsd.ComplexType(
        xsd.Sequence([
            xsd.Choice([
                xsd.Element('item_1', xsd.String()),
                xsd.Element('item_2', xsd.String())
            ])
        ])
    )
    args = tuple([])
    kwargs = {'item_2': 'value-2'}
    result = valueobjects._process_signature(xsd_type, args, kwargs)
    assert result == {'item_1': None, 'item_2': 'value-2'}
github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_choice_sequences_no_match():
    xsd_type = xsd.ComplexType(
        xsd.Sequence([
            xsd.Choice([
                xsd.Sequence([
                    xsd.Element('item_1', xsd.String()),
                    xsd.Element('item_2', xsd.String())
                ]),
                xsd.Sequence([
                    xsd.Element('item_3', xsd.String()),
                    xsd.Element('item_4', xsd.String())
                ]),
            ])
        ])
    )
    args = tuple([])
    with pytest.raises(TypeError):
        kwargs = {'item_1': 'value-1', 'item_3': 'value-3'}
        valueobjects._process_signature(xsd_type, args, kwargs)
github mvantellingen / python-zeep / tests / test_xsd.py View on Github external
def test_create_node():
    custom_type = xsd.Element(
        etree.QName("http://tests.python-zeep.org/", "authentication"),
        xsd.ComplexType(
            xsd.Sequence(
                [
                    xsd.Element(
                        etree.QName("http://tests.python-zeep.org/", "username"),
                        xsd.String(),
                    ),
                    xsd.Element(
                        etree.QName("http://tests.python-zeep.org/", "password"),
                        xsd.String(),
                    ),
                ]
            ),
            [xsd.Attribute("attr", xsd.String())],
        ),
    )

    # sequences
    obj = custom_type(username="foo", password="bar", attr="x")
github mvantellingen / python-zeep / tests / test_xsd_indicators_all.py View on Github external
def test_build_occurs_1():
    custom_type = xsd.Element(
        etree.QName("http://tests.python-zeep.org/", "authentication"),
        xsd.ComplexType(
            xsd.All(
                [
                    xsd.Element(
                        etree.QName("http://tests.python-zeep.org/", "item_1"),
                        xsd.String(),
                    ),
                    xsd.Element(
                        etree.QName("http://tests.python-zeep.org/", "item_2"),
                        xsd.String(),
                    ),
                ]
            )
        ),
    )
github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_pickle():
    xsd_type = xsd.ComplexType(
        xsd.Sequence(
            [xsd.Element("item_1", xsd.String()), xsd.Element("item_2", xsd.String())]
        )
    )

    obj = xsd_type(item_1="x", item_2="y")

    data = pickle.dumps(obj)
    obj_rt = pickle.loads(data)

    assert obj.item_1 == "x"
    assert obj.item_2 == "y"
    assert obj_rt.item_1 == "x"
    assert obj_rt.item_2 == "y"
github mvantellingen / python-zeep / tests / test_xsd_parse.py View on Github external
etree.QName("http://tests.python-zeep.org/", "authentication"),
        xsd.ComplexType(
            xsd.Sequence(
                [
                    xsd.Element(
                        etree.QName("http://tests.python-zeep.org/", "item_1"),
                        xsd.String(),
                    ),
                    xsd.Element(
                        etree.QName("http://tests.python-zeep.org/", "item_2"),
                        xsd.ComplexType(
                            xsd.Sequence(
                                [
                                    xsd.Choice(
                                        [
                                            xsd.Element(
                                                "{http://tests.python-zeep.org/}item_2a1",
                                                xsd.String(),
                                                min_occurs=0,
                                            ),
                                            xsd.Element(
                                                "{http://tests.python-zeep.org/}item_2a2",
                                                xsd.String(),
                                                min_occurs=0,
                                            ),
                                        ]
                                    ),
                                    xsd.Element(
                                        "{http://tests.python-zeep.org/}item_2b",
                                        xsd.String(),
                                    ),
                                ]
github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_choice_sequences_no_match_last():
    xsd_type = xsd.ComplexType(
        xsd.Sequence(
            [
                xsd.Choice(
                    [
                        xsd.Sequence(
                            [
                                xsd.Element("item_1", xsd.String()),
                                xsd.Element("item_2", xsd.String()),
                            ]
                        ),
                        xsd.Sequence(
                            [
                                xsd.Element("item_3", xsd.String()),
                                xsd.Element("item_4", xsd.String()),
                            ]
                        ),
                    ]
                )
            ]
        )
    )
    args = tuple([])
    with pytest.raises(TypeError):
        kwargs = {"item_2": "value-2", "item_4": "value-4"}
        valueobjects._process_signature(xsd_type, args, kwargs)
github mvantellingen / python-zeep / tests / test_xsd.py View on Github external
),
                        ]
                    ),
                    xsd.Choice(
                        [
                            xsd.Element(
                                etree.QName("http://tests.python-zeep.org/", "item_5"),
                                xsd.String(),
                            ),
                            xsd.Element(
                                etree.QName("http://tests.python-zeep.org/", "item_6"),
                                xsd.String(),
                            ),
                            xsd.Sequence(
                                [
                                    xsd.Element(
                                        etree.QName(
                                            "http://tests.python-zeep.org/", "item_7"
                                        ),
                                        xsd.String(),
                                    ),
                                    xsd.Element(
                                        etree.QName(
                                            "http://tests.python-zeep.org/", "item_8"
                                        ),
                                        xsd.String(),
                                    ),
                                ]
                            ),
                        ]
                    ),
                ]
github mvantellingen / python-zeep / tests / test_xsd_attributes.py View on Github external
def test_nested_attribute():
    schema = xsd.Schema(
        load_xml(
            """
        
        
          <element name="container">
            
              
                <element name="item">
                    
                        
                            <element name="x">
                        </element></element></element>
github mvantellingen / python-zeep / tests / test_xsd_indicators_group.py View on Github external
def test_xml_group_methods():
    schema = xsd.Schema(
        load_xml(
            """
        
        

          
            
              blub