Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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(
[
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,
)
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"}
""".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
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"}
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)
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()),
]
),
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'}
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(),
]
)
),
)
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)
)