How to use the zeep.xsd.String 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_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_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_xsd.py View on Github external
def test_xsi():
    org_type = xsd.Element(
        "{https://tests.python-zeep.org/}original",
        xsd.ComplexType(
            xsd.Sequence(
                [
                    xsd.Element("username", xsd.String()),
                    xsd.Element("password", xsd.String()),
                ]
            )
        ),
    )
    alt_type = xsd.Element(
        "{https://tests.python-zeep.org/}alternative",
        xsd.ComplexType(
            xsd.Sequence(
                [
                    xsd.Element("username", xsd.String()),
                    xsd.Element("password", xsd.String()),
                ]
            )
        ),
    )
    instance = alt_type(username="mvantellingen", password="geheim")
github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_simple_args_attributes():
    xsd_type = xsd.ComplexType(
        xsd.Sequence(
            [xsd.Element("item_1", xsd.String()), xsd.Element("item_2", xsd.String())]
        ),
        [xsd.Attribute("attr_1", xsd.String())],
    )
    args = tuple(["value-1", "value-2", "bla"])
    kwargs = {}
    result = valueobjects._process_signature(xsd_type, args, kwargs)
    assert result == {"item_1": "value-1", "item_2": "value-2", "attr_1": "bla"}
github mvantellingen / python-zeep / tests / test_xsd_valueobjects.py View on Github external
def test_simple_args_attributes_as_kwargs():
    xsd_type = xsd.ComplexType(
        xsd.Sequence(
            [xsd.Element("item_1", xsd.String()), xsd.Element("item_2", xsd.String())]
        ),
        [xsd.Attribute("attr_1", xsd.String())],
    )
    args = tuple(["value-1", "value-2"])
    kwargs = {"attr_1": "bla"}
    result = valueobjects._process_signature(xsd_type, args, kwargs)
    assert result == {"item_1": "value-1", "item_2": "value-2", "attr_1": "bla"}
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(),
                                )
                            ]
                        ),
                    ),
                ]
            )
github mvantellingen / python-zeep / tests / test_xsd_indicators_sequence.py View on Github external
def test_build_min_occurs_2_max_occurs_2():
    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,
            )
        ),
    )

    assert custom_type.signature()

    elm = custom_type(
        _value_1=[
github mvantellingen / python-zeep / tests / test_xsd_indicators_all.py View on Github external
def test_build_pare_other_order():
    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(),
                    ),
                ]
            )
        ),
    )

    xml = load_xml(
        """
        
          
            bar
            foo
          
        
    """
    )
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
xsd_type = xsd.ComplexType(
        xsd.Sequence(
            [
                xsd.Choice(
                    [
                        xsd.Sequence(
                            [
                                xsd.Element("item_1", xsd.String()),
                                xsd.Element("item_2", xsd.String(), min_occurs=0),
                            ]
                        ),
                        xsd.Sequence(
                            [
                                xsd.Element("item_1", xsd.String()),
                                xsd.Element("item_2", xsd.String()),
                                xsd.Element("item_3", xsd.String()),
                            ]
                        ),
                    ]
                )
            ]
        )
    )
    args = tuple([])
    kwargs = {"item_1": "value-1"}
    result = valueobjects._process_signature(xsd_type, args, kwargs)
    assert result == {"item_1": "value-1", "item_2": None, "item_3": None}