Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()),
]
),
]
)
]
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(
etree.QName("http://tests.python-zeep.org/", "item_4"),
xsd.String(),
),
]
),
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_5"
),
xsd.String(),
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"}
def test_choice_determinst():
root = xsd.Element(
etree.QName("http://tests.python-zeep.org/", "kies"),
xsd.ComplexType(
xsd.Sequence(
[
xsd.Choice(
[
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(),
),
]
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(
etree.QName("http://tests.python-zeep.org/", "item_4"),
xsd.String(),
),
]
),
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(),
def test_signature_complex_type_choice_sequence():
custom_type = xsd.Element(
etree.QName("http://tests.python-zeep.org/", "authentication"),
xsd.ComplexType(
xsd.Choice(
[
xsd.Element(
etree.QName("http://tests.python-zeep.org/", "item_1"),
xsd.String(),
),
xsd.Sequence(
[
xsd.Element(
etree.QName(
"http://tests.python-zeep.org/", "item_2_1"
),
xsd.String(),
),
xsd.Element(
etree.QName(
"http://tests.python-zeep.org/", "item_2_2"
def test_choice_max_occurs():
fields = xsd.ComplexType(
xsd.Sequence([
xsd.Choice([
xsd.Element('item_1', xsd.String()),
xsd.Element('item_2', xsd.String())
], max_occurs=3)
])
)
args = tuple([])
kwargs = {
'_value_1': [
{'item_1': 'foo'}, {'item_2': 'bar'}, {'item_1': 'bla'}
]
}
result = valueobjects._process_signature(fields, args, kwargs)
assert result == {
'_value_1': [
{'item_1': 'foo'},
{'item_2': 'bar'},
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"}]}
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()),
]
),
],
max_occurs=2,
)
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()),
]),
], max_occurs=2)
]),
)
args = tuple([])
kwargs = {
'_value_1': [
{'item_1': 'value-1', 'item_2': 'value-2'},
{'item_2': 'value-2', 'item_3': 'value-3'},