forked from mvantellingen/python-zeep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_xsd_indicators_all.py
79 lines (68 loc) · 2.15 KB
/
test_xsd_indicators_all.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from lxml import etree
from tests.utils import assert_nodes_equal, load_xml, render_node
from zeep import xsd
def test_build_occurs_1():
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(),
),
]
)
),
)
obj = custom_type(item_1="foo", item_2="bar")
result = render_node(custom_type, obj)
expected = load_xml(
"""
<document>
<ns0:authentication xmlns:ns0="http://tests.python-zeep.org/">
<ns0:item_1>foo</ns0:item_1>
<ns0:item_2>bar</ns0:item_2>
</ns0:authentication>
</document>
"""
)
assert_nodes_equal(result, expected)
obj = custom_type.parse(result[0], None)
assert obj.item_1 == "foo"
assert obj.item_2 == "bar"
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(
"""
<document>
<ns0:authentication xmlns:ns0="http://tests.python-zeep.org/">
<ns0:item_2>bar</ns0:item_2>
<ns0:item_1>foo</ns0:item_1>
</ns0:authentication>
</document>
"""
)
obj = custom_type.parse(xml[0], None)
assert obj.item_1 == "foo"
assert obj.item_2 == "bar"