forked from mvantellingen/python-zeep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_client_factory.py
44 lines (31 loc) · 1.4 KB
/
test_client_factory.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
import pytest
from zeep import Client
def test_factory_namespace():
client = Client("tests/wsdl_files/soap.wsdl")
factory = client.type_factory("http://example.com/stockquote.xsd")
obj = factory.Address(NameFirst="Michael", NameLast="van Tellingen")
assert obj.NameFirst == "Michael"
assert obj.NameLast == "van Tellingen"
def test_factory_no_reference():
client = Client("tests/wsdl_files/soap.wsdl")
obj_1 = client.get_type("ns0:ArrayOfAddress")()
obj_1.Address.append({"NameFirst": "J", "NameLast": "Doe"})
obj_2 = client.get_type("ns0:ArrayOfAddress")()
assert len(obj_2.Address) == 0
def test_factory_ns_auto_prefix():
client = Client("tests/wsdl_files/soap.wsdl")
factory = client.type_factory("ns0")
obj = factory.Address(NameFirst="Michael", NameLast="van Tellingen")
assert obj.NameFirst == "Michael"
assert obj.NameLast == "van Tellingen"
def test_factory_ns_custom_prefix():
client = Client("tests/wsdl_files/soap.wsdl")
client.set_ns_prefix("sq", "http://example.com/stockquote.xsd")
factory = client.type_factory("sq")
obj = factory.Address(NameFirst="Michael", NameLast="van Tellingen")
assert obj.NameFirst == "Michael"
assert obj.NameLast == "van Tellingen"
def test_factory_ns_unknown_prefix():
client = Client("tests/wsdl_files/soap.wsdl")
with pytest.raises(ValueError):
client.type_factory("bla")