How to use the zeep.xsd.Sequence function in zeep

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_indicators_group.py View on Github external
def test_build_objects():
    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.Group(
                        etree.QName("http://tests.python-zeep.org/", "groupie"),
                        xsd.Sequence(
                            [
                                xsd.Element(
                                    etree.QName(
                                        "http://tests.python-zeep.org/", "password"
                                    ),
                                    xsd.String(),
                                )
                            ]
                        ),
                    ),
                ]
            )
        ),
    )
    assert custom_type.signature()
    obj = custom_type(username="foo", password="bar")
github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_choice_max_occurs_simple_interface():
    fields = xsd.ComplexType(
        xsd.Sequence(
            [
                xsd.Choice(
                    [
                        xsd.Element("item_1", xsd.String()),
                        xsd.Element("item_2", xsd.String()),
                    ],
                    max_occurs=2,
                )
            ]
        )
    )
    args = tuple([])
    kwargs = {"_value_1": [{"item_1": "foo"}, {"item_2": "bar"}]}
    result = valueobjects._process_signature(fields, args, kwargs)
    assert result == {"_value_1": [{"item_1": "foo"}, {"item_2": "bar"}]}
github mvantellingen / python-zeep / tests / test_xsd.py View on Github external
def test_complex_type():
    custom_type = 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(),
                ),
            ]
        )
    )
    obj = custom_type("user", "pass")
    assert {key: obj[key] for key in obj} == {"username": "user", "password": "pass"}
github mvantellingen / python-zeep / tests / test_xsd.py View on Github external
),
                    xsd.Element(
                        "{http://tests.python-zeep.org/}item_2",
                        xsd.DateTime(),
                        nillable=True,
                    ),
                    xsd.Element(
                        "{http://tests.python-zeep.org/}item_3",
                        xsd.String(),
                        min_occurs=0,
                        nillable=False,
                    ),
                    xsd.Element(
                        "{http://tests.python-zeep.org/}item_4",
                        xsd.ComplexType(
                            xsd.Sequence(
                                [
                                    xsd.Element(
                                        "{http://tests.python-zeep.org/}item_4_1",
                                        xsd.String(),
                                        nillable=True,
                                    )
                                ]
                            )
                        ),
                    ),
                    xsd.Element(
                        "{http://tests.python-zeep.org/}item_5",
                        xsd.ComplexType(
                            xsd.Sequence(
                                [
                                    xsd.Element(
github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_choice_sequences_no_match_nested():
    xsd_type = xsd.ComplexType(
        xsd.Sequence(
            [
                xsd.Choice(
                    [
                        xsd.Sequence(
                            [
                                xsd.Element("item_1", xsd.String()),
                                xsd.Element("item_2", xsd.String()),
                            ]
                        )
                    ]
                )
            ]
        )
    )
    args = tuple([])
    kwargs = {"item_1": "value-1"}
    value = valueobjects._process_signature(xsd_type, args, kwargs)
    assert value == {"item_1": "value-1", "item_2": None}
github mvantellingen / python-zeep / tests / test_xsd.py View on Github external
def test_container_elements():
    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.Any(),
                ]
            )
        ),
    )

    # sequences
github mvantellingen / python-zeep / tests / test_xsd_indicators_sequence.py View on Github external
def test_build_min_occurs_2_max_occurs_2_error():
    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/", "item_1"),
                        xsd.String(),
                    ),
                    xsd.Element(
                        etree.QName("http://tests.python-zeep.org/", "item_2"),
                        xsd.String(),
                    ),
                ],
                min_occurs=2,
                max_occurs=2,
            )
        ),
    )
github mvantellingen / python-zeep / tests / test_xsd.py View on Github external
def test_mixed_choice():
    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/", "item_1"),
                        xsd.String(),
                    ),
                    xsd.Element(
                        etree.QName("http://tests.python-zeep.org/", "item_2"),
                        xsd.String(),
                    ),
                    xsd.Sequence(
                        [
                            xsd.Element(
                                etree.QName("http://tests.python-zeep.org/", "item_3"),
                                xsd.String(),
                            ),
                            xsd.Element(
github mvantellingen / python-zeep / tests / test_xsd_indicators_group.py View on Github external
def test_build_group_min_occurs_1():
    custom_type = xsd.Element(
        etree.QName("http://tests.python-zeep.org/", "authentication"),
        xsd.ComplexType(
            xsd.Group(
                etree.QName("http://tests.python-zeep.org/", "foobar"),
                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.String(),
                        ),
                    ]
                ),
                min_occurs=1,
            )
        ),
    )