本文整理汇总了Python中testutils.client_from_wsdl函数的典型用法代码示例。如果您正苦于以下问题:Python client_from_wsdl函数的具体用法?Python client_from_wsdl怎么用?Python client_from_wsdl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了client_from_wsdl函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_bare_input_restriction_types
def test_bare_input_restriction_types():
client_unnamed = testutils.client_from_wsdl(testutils.wsdl("""\
<xsd:element name="Elemento">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="alfa"/>
<xsd:enumeration value="beta"/>
<xsd:enumeration value="gamma"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>""", input="Elemento", operation_name="f"))
client_named = testutils.client_from_wsdl(testutils.wsdl("""\
<xsd:simpleType name="MyType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="alfa"/>
<xsd:enumeration value="beta"/>
<xsd:enumeration value="gamma"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Elemento" type="ns:MyType"/>""", input="Elemento",
operation_name="f"))
assert not _is_input_wrapped(client_unnamed, "f")
assert not _is_input_wrapped(client_named, "f")
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:25,代码来源:test_request_construction.py
示例2: test_fault_reply_with_unicode_faultstring
def test_fault_reply_with_unicode_faultstring(monkeypatch):
monkeypatch.delitem(locals(), "e", False)
unicode_string = u("\\u20AC Jurko Gospodneti\\u0107 "
"\\u010C\\u0106\\u017D\\u0160\\u0110"
"\\u010D\\u0107\\u017E\\u0161\\u0111")
fault_xml = suds.byte_str(u("""\
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<env:Fault>
<faultcode>env:Client</faultcode>
<faultstring>%s</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>
""") % (unicode_string,))
client = testutils.client_from_wsdl(_wsdl__simple_f, faults=True)
inject = dict(reply=fault_xml, status=http_client.INTERNAL_SERVER_ERROR)
e = pytest.raises(suds.WebFault, client.service.f, __inject=inject).value
try:
assert e.fault.faultstring == unicode_string
assert e.document.__class__ is suds.sax.document.Document
finally:
del e # explicitly break circular reference chain in Python 3
client = testutils.client_from_wsdl(_wsdl__simple_f, faults=False)
status, fault = client.service.f(__inject=dict(reply=fault_xml,
status=http_client.INTERNAL_SERVER_ERROR))
assert status == http_client.INTERNAL_SERVER_ERROR
assert fault.faultstring == unicode_string
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:32,代码来源:test_reply_handling.py
示例3: test_restriction_data_types
def test_restriction_data_types():
client_unnamed = testutils.client_from_wsdl(testutils.wsdl("""\
<xsd:element name="Elemento">
<xsd:simpleType>
<xsd:restriction base="xsd:int">
<xsd:enumeration value="1"/>
<xsd:enumeration value="3"/>
<xsd:enumeration value="5"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>""", output="Elemento"))
client_named = testutils.client_from_wsdl(testutils.wsdl("""\
<xsd:simpleType name="MyType">
<xsd:restriction base="xsd:int">
<xsd:enumeration value="1"/>
<xsd:enumeration value="3"/>
<xsd:enumeration value="5"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Elemento" type="ns:MyType"/>""", output="Elemento"))
client_twice_restricted = testutils.client_from_wsdl(testutils.wsdl("""\
<xsd:simpleType name="MyTypeGeneric">
<xsd:restriction base="xsd:int">
<xsd:enumeration value="1"/>
<xsd:enumeration value="2"/>
<xsd:enumeration value="3"/>
<xsd:enumeration value="4"/>
<xsd:enumeration value="5"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="MyType">
<xsd:restriction base="ns:MyTypeGeneric">
<xsd:enumeration value="1"/>
<xsd:enumeration value="3"/>
<xsd:enumeration value="5"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Elemento" type="ns:MyType"/>""", output="Elemento"))
for client in (client_unnamed, client_named, client_twice_restricted):
response = client.service.f(__inject=dict(reply=suds.byte_str("""\
<?xml version="1.0"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<Elemento xmlns="my-namespace">5</Elemento>
</Body>
</Envelope>""")))
assert response.__class__ is int
assert response == 5
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:51,代码来源:test_reply_handling.py
示例4: test_reply_error_without_detail_with_fault
def test_reply_error_without_detail_with_fault(monkeypatch):
monkeypatch.delitem(locals(), "e", False)
client = testutils.client_from_wsdl(_wsdl__simple_f, faults=True)
for http_status in (http_client.OK, http_client.INTERNAL_SERVER_ERROR):
inject = dict(reply=_fault_reply__without_detail, status=http_status)
e = pytest.raises(suds.WebFault, client.service.f, __inject=inject)
try:
e = e.value
_test_fault(e.fault, False)
assert e.document.__class__ is suds.sax.document.Document
assert str(e) == "Server raised fault: 'Dummy error.'"
finally:
del e # explicitly break circular reference chain in Python 3
inject = dict(reply=_fault_reply__with_detail,
status=http_client.BAD_REQUEST, description="quack-quack")
e = pytest.raises(Exception, client.service.f, __inject=inject).value
try:
assert e.__class__ is Exception
assert e.args[0][0] == http_client.BAD_REQUEST
assert e.args[0][1] == "quack-quack"
finally:
del e # explicitly break circular reference chain in Python 3
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:25,代码来源:test_reply_handling.py
示例5: test_invalid_fault_namespace
def test_invalid_fault_namespace(monkeypatch):
monkeypatch.delitem(locals(), "e", False)
fault_xml = suds.byte_str("""\
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:p="x">
<env:Body>
<p:Fault>
<faultcode>env:Client</faultcode>
<faultstring>Dummy error.</faultstring>
<detail>
<errorcode>ultimate</errorcode>
</detail>
</p:Fault>
</env:Body>
</env:Envelope>
""")
client = testutils.client_from_wsdl(_wsdl__simple_f, faults=False)
inject = dict(reply=fault_xml, status=http_client.OK)
e = pytest.raises(Exception, client.service.f, __inject=inject).value
try:
assert e.__class__ is Exception
assert str(e) == "<faultcode/> not mapped to message part"
finally:
del e # explicitly break circular reference chain in Python 3
for http_status in (http_client.INTERNAL_SERVER_ERROR,
http_client.PAYMENT_REQUIRED):
status, reason = client.service.f(__inject=dict(reply=fault_xml,
status=http_status, description="trla baba lan"))
assert status == http_status
assert reason == "trla baba lan"
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:32,代码来源:test_reply_handling.py
示例6: test_disabling_automated_simple_interface_unwrapping
def test_disabling_automated_simple_interface_unwrapping():
xsd_target_namespace = "woof"
wsdl = testutils.wsdl(
"""\
<xsd:element name="Wrapper">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Elemento" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>""",
input="Wrapper",
operation_name="f",
xsd_target_namespace=xsd_target_namespace,
)
client = testutils.client_from_wsdl(wsdl, nosend=True, prettyxml=True, unwrap=False)
assert not _is_input_wrapped(client, "f")
element_data = "Wonderwall"
wrapper = client.factory.create("my_xsd:Wrapper")
wrapper.Elemento = element_data
_assert_request_content(
client.service.f(Wrapper=wrapper),
"""\
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Header/>
<Body>
<Wrapper xmlns="%s">
<Elemento>%s</Elemento>
</Wrapper>
</Body>
</Envelope>"""
% (xsd_target_namespace, element_data),
)
开发者ID:overcastcloud,项目名称:suds-jurko,代码行数:34,代码来源:test_request_construction.py
示例7: test_SOAP_headers
def test_SOAP_headers():
"""Rudimentary 'soapheaders' option usage test."""
wsdl = suds.byte_str("""\
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions targetNamespace="my-target-namespace"
xmlns:tns="my-target-namespace"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified"
targetNamespace="my-target-namespace">
<s:element name="MyHeader">
<s:complexType>
<s:sequence>
<s:element name="Freaky" type="s:hexBinary"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="myOperationHeader">
<wsdl:part name="MyHeader" element="tns:MyHeader"/>
</wsdl:message>
<wsdl:portType name="MyWSSOAP">
<wsdl:operation name="my_operation"/>
</wsdl:portType>
<wsdl:binding name="MyWSSOAP" type="tns:MyWSSOAP">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="my_operation">
<soap:operation soapAction="my-SOAP-action" style="document"/>
<wsdl:input>
<soap:header message="tns:myOperationHeader" part="MyHeader"
use="literal"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MyWS">
<wsdl:port name="MyWSSOAP" binding="tns:MyWSSOAP">
<soap:address location="protocol://my-WS-URL"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
""")
header_data = "fools rush in where angels fear to tread"
client = testutils.client_from_wsdl(wsdl, nosend=True, prettyxml=True)
client.options.soapheaders = header_data
_assert_request_content(client.service.my_operation(), """\
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Header>
<MyHeader xmlns="my-target-namespace">%s</MyHeader>
</Header>
<Body/>
</Envelope>""" % (header_data,))
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:60,代码来源:test_request_construction.py
示例8: test_disabling_automated_simple_interface_unwrapping
def test_disabling_automated_simple_interface_unwrapping():
client = testutils.client_from_wsdl(testutils.wsdl("""\
<xsd:element name="Wrapper">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Elemento" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>""", output="Wrapper"), unwrap=False)
assert not _isOutputWrapped(client, "f")
response = client.service.f(__inject=dict(reply=suds.byte_str("""\
<?xml version="1.0"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<Wrapper xmlns="my-namespace">
<Elemento>La-di-da-da-da</Elemento>
</Wrapper>
</Body>
</Envelope>""")))
assert response.__class__.__name__ == "Wrapper"
assert len(response.__class__.__bases__) == 1
assert response.__class__.__bases__[0] is suds.sudsobject.Object
assert response.Elemento.__class__ is suds.sax.text.Text
assert response.Elemento == "La-di-da-da-da"
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:26,代码来源:test_reply_handling.py
示例9: test_twice_wrapped_parameter
def test_twice_wrapped_parameter():
"""
Suds does not recognize 'twice wrapped' data structures and unwraps the
external one but keeps the internal wrapping structure in place.
"""
xsd_target_namespace = "spank me"
wsdl = testutils.wsdl("""\
<xsd:element name="Wrapper1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Wrapper2">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Elemento" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>""", input="Wrapper1", operation_name="f",
xsd_target_namespace=xsd_target_namespace)
client = testutils.client_from_wsdl(wsdl, nosend=True, prettyxml=True)
assert _is_input_wrapped(client, "f")
# Web service operation calls made with 'valid' parameters.
#
# These calls are actually illegal and result in incorrectly generated SOAP
# requests not matching the relevant WSDL schema. To make them valid we
# would need to pass a more complex value instead of a simple string, but
# the current simpler solution is good enough for what we want to test
# here.
value = "A B C"
expected_request = """\
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Header/>
<Body>
<Wrapper1 xmlns="%s">
<Wrapper2>%s</Wrapper2>
</Wrapper1>
</Body>
</Envelope>""" % (xsd_target_namespace, value)
_assert_request_content(client.service.f(value), expected_request)
_assert_request_content(client.service.f(Wrapper2=value), expected_request)
# Web service operation calls made with 'invalid' parameters.
def test_invalid_parameter(**kwargs):
assert len(kwargs) == 1
keyword = next(iterkeys(kwargs))
expected = "f() got an unexpected keyword argument '%s'" % (keyword,)
e = pytest.raises(TypeError, client.service.f, **kwargs).value
try:
assert str(e) == expected
finally:
del e # explicitly break circular reference chain in Python 3
test_invalid_parameter(Elemento=value)
test_invalid_parameter(Wrapper1=value)
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:59,代码来源:test_request_construction.py
示例10: _create_dummy_schema
def _create_dummy_schema():
"""Constructs a new dummy XSD schema instance."""
#TODO: Find out how to construct this XSD schema object directly without
# first having to construct a suds.client.Client from a complete WSDL
# schema.
wsdl = testutils.wsdl('<xsd:element name="dummy"/>', input="dummy")
client = testutils.client_from_wsdl(wsdl)
return client.wsdl.schema
开发者ID:codingkevin,项目名称:suds,代码行数:8,代码来源:test_xsd_builtins.py
示例11: test_simple_bare_and_wrapped_output
def test_simple_bare_and_wrapped_output():
# Prepare web service proxies.
client_bare = testutils.client_from_wsdl(testutils.wsdl("""\
<xsd:element name="fResponse" type="xsd:string"/>""",
output="fResponse"))
client_wrapped = testutils.client_from_wsdl(testutils.wsdl("""\
<xsd:element name="Wrapper">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="fResponse" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>""", output="Wrapper"))
# Make sure suds library inteprets our WSDL definitions as wrapped or bare
# output interfaces as expected.
assert not _isOutputWrapped(client_bare, "f")
assert _isOutputWrapped(client_wrapped, "f")
# Both bare & wrapped single parameter output web service operation results
# get presented the same way even though the wrapped one actually has an
# extra wrapper element around its received output data.
data = "The meaning of life."
def get_response(client, x):
return client.service.f(__inject=dict(reply=suds.byte_str(x)))
response_bare = get_response(client_bare, """<?xml version="1.0"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<fResponse xmlns="my-namespace">%s</fResponse>
</Body>
</Envelope>""" % (data,))
assert response_bare.__class__ is suds.sax.text.Text
assert response_bare == data
response_wrapped = get_response(client_wrapped, """<?xml version="1.0"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<Wrapper xmlns="my-namespace">
<fResponse>%s</fResponse>
</Wrapper>
</Body>
</Envelope>""" % (data,))
assert response_wrapped.__class__ is suds.sax.text.Text
assert response_wrapped == data
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:45,代码来源:test_reply_handling.py
示例12: _service_from_wsdl
def _service_from_wsdl(wsdl):
"""
Construct a suds Client service instance used in tests in this module.
The constructed Client instance only prepares web service operation
invocation requests and does not attempt to actually send them.
"""
return testutils.client_from_wsdl(wsdl, nosend=True, prettyxml=True).service
开发者ID:overcastcloud,项目名称:suds-jurko,代码行数:9,代码来源:test_request_construction.py
示例13: test_ACCEPTED_and_NO_CONTENT_status_reported_as_None_without_faults
def test_ACCEPTED_and_NO_CONTENT_status_reported_as_None_without_faults():
client = testutils.client_from_wsdl(_wsdl__simple_f, faults=False)
def f(reply, status):
inject = {"reply": suds.byte_str(reply), "status": status}
return client.service.f(__inject=inject)
assert f("", None) is not None
assert f("", http_client.INTERNAL_SERVER_ERROR) is not None
assert f("", http_client.ACCEPTED) is None
assert f("", http_client.NO_CONTENT) is None
assert f("bla-bla", http_client.ACCEPTED) is None
assert f("bla-bla", http_client.NO_CONTENT) is None
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:11,代码来源:test_reply_handling.py
示例14: test_document_literal_request_for_single_element_input
def test_document_literal_request_for_single_element_input(xsd,
external_element_name, args, request_body):
wsdl = testutils.wsdl(xsd, input=external_element_name,
xsd_target_namespace="dr. Doolittle", operation_name="f")
client = testutils.client_from_wsdl(wsdl, nosend=True, prettyxml=True)
_assert_request_content(client.service.f(*args), """\
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body xmlns="dr. Doolittle">%s</SOAP-ENV:Body>
</SOAP-ENV:Envelope>""" % (request_body,))
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:11,代码来源:test_request_construction.py
示例15: test_builtin_typed_element_parameter
def test_builtin_typed_element_parameter(part_name):
"""
Test correctly recognizing web service operation input structure defined by
a built-in typed element.
"""
wsdl = suds.byte_str("""\
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions targetNamespace="my-namespace"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:ns="my-namespace"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<xsd:schema targetNamespace="my-namespace"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="MyElement" type="xsd:integer" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="fRequestMessage">
<wsdl:part name="%s" element="ns:MyElement" />
</wsdl:message>
<wsdl:portType name="dummyPortType">
<wsdl:operation name="f">
<wsdl:input message="ns:fRequestMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="dummy" type="ns:dummyPortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="f">
<soap:operation soapAction="my-soap-action" style="document" />
<wsdl:input><soap:body use="literal" /></wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="dummy">
<wsdl:port name="dummy" binding="ns:dummy">
<soap:address location="unga-bunga-location" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>""" % (part_name,))
client = testutils.client_from_wsdl(wsdl, nosend=True)
# Collect references to required WSDL model content.
method = client.wsdl.services[0].ports[0].methods["f"]
assert not method.soap.input.body.wrapped
binding = method.binding.input
assert binding.__class__ is suds.bindings.document.Document
my_element = client.wsdl.schema.elements["MyElement", "my-namespace"]
param_defs = binding.param_defs(method)
_expect_params(param_defs, [("MyElement", my_element)])
开发者ID:codingkevin,项目名称:suds,代码行数:53,代码来源:test_input_parameters.py
示例16: test_binding_uses_argument_parsing
def test_binding_uses_argument_parsing(monkeypatch, binding_style):
"""
Calling web service operations should use the generic argument parsing
functionality independent of the operation's specific binding style.
"""
class MyException(Exception):
pass
def raise_exception(*args, **kwargs):
raise MyException
monkeypatch.setattr(suds.argparser._ArgParser, "__init__", raise_exception)
wsdl = suds.byte_str("""\
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions targetNamespace="my-namespace"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:ns="my-namespace"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<xsd:schema targetNamespace="my-namespace"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Bongo" type="xsd:string" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="fRequestMessage">"
<wsdl:part name="parameters" element="ns:Bongo" />
</wsdl:message>
<wsdl:portType name="dummyPortType">
<wsdl:operation name="f">
<wsdl:input message="ns:fRequestMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="dummy" type="ns:dummyPortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="f">
<soap:operation soapAction="my-soap-action" style="%s" />
<wsdl:input><soap:body use="literal" /></wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="dummy">
<wsdl:port name="dummy" binding="ns:dummy">
<soap:address location="unga-bunga-location" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
""" % (binding_style,))
client = testutils.client_from_wsdl(wsdl, nosend=True, prettyxml=True)
pytest.raises(MyException, client.service.f)
pytest.raises(MyException, client.service.f, "x")
pytest.raises(MyException, client.service.f, "x", "y")
开发者ID:EASYMARKETING,项目名称:suds-jurko,代码行数:53,代码来源:test_argument_parser.py
示例17: test_operation_invoke_with_urlopen_accept_no_content__data
def test_operation_invoke_with_urlopen_accept_no_content__data(self, status_code):
"""
suds.client.Client web service operation invocation expecting output
data, and for which a corresponding urlopen call raises a HTTPError
with status code ACCEPTED or NO_CONTENT, should report this as a
TransportError.
"""
e = self.create_HTTPError(code=status_code)
transport = suds.transport.http.HttpTransport()
transport.urlopener = MockURLOpenerSaboteur(open_exception=e)
wsdl = testutils.wsdl('<xsd:element name="o" type="xsd:string"/>', output="o", operation_name="f")
client = testutils.client_from_wsdl(wsdl, transport=transport)
pytest.raises(suds.transport.TransportError, client.service.f)
开发者ID:EASYMARKETING,项目名称:suds-jurko,代码行数:14,代码来源:test_transport_http.py
示例18: test_reply_error_without_detail_without_fault
def test_reply_error_without_detail_without_fault():
client = testutils.client_from_wsdl(_wsdl__simple_f, faults=False)
for http_status in (http_client.OK, http_client.INTERNAL_SERVER_ERROR):
status, fault = client.service.f(__inject=dict(
reply=_fault_reply__without_detail, status=http_status))
assert status == http_client.INTERNAL_SERVER_ERROR
_test_fault(fault, False)
status, fault = client.service.f(__inject=dict(
reply=_fault_reply__without_detail, status=http_client.BAD_REQUEST,
description="kung-fu-fui"))
assert status == http_client.BAD_REQUEST
assert fault == "kung-fu-fui"
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:14,代码来源:test_reply_handling.py
示例19: test_optional_parameter_with_empty_object_value
def test_optional_parameter_with_empty_object_value():
"""Missing optional parameters should not get passed at all."""
xsd_target_namespace = "I'm a cute little swamp gorilla monster!"
wsdl = testutils.wsdl("""\
<xsd:element name="Wrapper">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:anyType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>""", input="Wrapper", operation_name="f",
xsd_target_namespace=xsd_target_namespace)
client = testutils.client_from_wsdl(wsdl, nosend=True, prettyxml=True)
service = client.service
# Base line: nothing passed --> nothing marshalled.
_assert_request_content(service.f(), """\
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Header/>
<Body>
<Wrapper xmlns="%s"/>
</Body>
</Envelope>""" % (xsd_target_namespace,))
# Passing a empty object as an empty dictionary.
_assert_request_content(service.f({}), """\
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Header/>
<Body>
<Wrapper xmlns="%s">
<value/>
</Wrapper>
</Body>
</Envelope>""" % (xsd_target_namespace,))
# Passing a empty explicitly constructed `suds.sudsobject.Object`.
empty_object = client.factory.create("my_xsd:Wrapper")
_assert_request_content(service.f(empty_object), """\
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Header/>
<Body>
<Wrapper xmlns="%s">
<value/>
</Wrapper>
</Body>
</Envelope>""" % (xsd_target_namespace,))
开发者ID:IvarsKarpics,项目名称:edna-mx,代码行数:49,代码来源:test_request_construction.py
示例20: test_resolving_builtin_types
def test_resolving_builtin_types(monkeypatch):
_monkeypatch_builtin_XSD_type_registry(monkeypatch)
class MockXInteger(XInteger):
pass
Factory.maptag("osama", MockXInteger)
wsdl = testutils.wsdl('<xsd:element name="wu" type="xsd:osama"/>',
input="wu")
client = testutils.client_from_wsdl(wsdl)
element, schema_object = client.sd[0].params[0]
assert element.name == "wu"
assert element.type == ("osama", "http://www.w3.org/2001/XMLSchema")
assert schema_object.__class__ is MockXInteger
assert schema_object.name == "osama"
assert schema_object.schema is client.wsdl.schema
开发者ID:codingkevin,项目名称:suds,代码行数:16,代码来源:test_xsd_builtins.py
注:本文中的testutils.client_from_wsdl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论