How to use the zeep.xsd.ComplexType 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.py View on Github external
nillable=True,
                    ),
                    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(
                                [
github mvantellingen / python-zeep / tests / test_xsd_indicators_group.py View on Github external
def test_build_group_min_occurs_1_parse_args():
    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,
            )
github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_simple_args():
    xsd_type = xsd.ComplexType(
        xsd.Sequence(
            [xsd.Element("item_1", xsd.String()), xsd.Element("item_2", xsd.String())]
        )
    )
    args = tuple(["value-1", "value-2"])
    kwargs = {}
    result = valueobjects._process_signature(xsd_type, args, kwargs)
    assert result == {"item_1": "value-1", "item_2": "value-2"}
github mvantellingen / python-zeep / tests / test_wsdl_messages_document.py View on Github external
""".strip()
    )

    root = wsdl.Document(wsdl_content, None)

    binding = root.bindings["{http://tests.python-zeep.org/tns}TestBinding"]
    operation = binding.get("TestOperation")

    header = xsd.Element(
        "{http://test.python-zeep.org/custom}auth",
        xsd.ComplexType(
            [xsd.Element("{http://test.python-zeep.org/custom}username", xsd.String())]
        ),
    )

    serialized = operation.input.serialize(
        arg1="ah1", arg2="ah2", _soapheaders=[header(username="mvantellingen")]
    )

    expected = """
        
        
          
            
              mvantellingen
github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_simple_kwargs():
    xsd_type = xsd.ComplexType(
        xsd.Sequence(
            [xsd.Element("item_1", xsd.String()), xsd.Element("item_2", xsd.String())]
        )
    )
    args = tuple([])
    kwargs = {"item_1": "value-1", "item_2": "value-2"}
    result = valueobjects._process_signature(xsd_type, args, kwargs)
    assert result == {"item_1": "value-1", "item_2": "value-2"}
github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_choice_sequences_simple():
    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([])
    kwargs = {'item_1': 'value-1', 'item_2': 'value-2'}
    result = valueobjects._process_signature(xsd_type, args, kwargs)
github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_choice_sequences_max_occur():
    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_2", xsd.String()),
                                xsd.Element("item_3", 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'}
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(),
                ]
            )
        ),
    )
github mvantellingen / python-zeep / src / zeep / wsdl / messages / soap.py View on Github external
all_elements = xsd.Sequence([])

        if self.header.type._element:
            all_elements.append(
                xsd.Element("{%s}header" % self.nsmap["soap-env"], self.header.type)
            )

        all_elements.append(
            xsd.Element(
                "{%s}body" % self.nsmap["soap-env"],
                self.body.type if self.body else None,
            )
        )

        return xsd.Element(
            "{%s}envelope" % self.nsmap["soap-env"], xsd.ComplexType(all_elements)
        )