• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python testutil.echo_service函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中soapfish.testutil.echo_service函数的典型用法代码示例。如果您正苦于以下问题:Python echo_service函数的具体用法?Python echo_service怎么用?Python echo_service使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了echo_service函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_can_reject_invalid_root_tag

 def test_can_reject_invalid_root_tag(self):
     soap_message = ('<ns0:invalid xmlns:ns0="invalid"/>')
     request_message = self._wrap_with_soap_envelope(soap_message)
     request = SOAPRequest(dict(REQUEST_METHOD='POST'), request_message)
     dispatcher = SOAPDispatcher(echo_service())
     response = dispatcher.dispatch(request)
     self.assert_is_soap_fault(response, partial_fault_string="DocumentInvalid")
开发者ID:pricez,项目名称:soapfish,代码行数:7,代码来源:soap_dispatcher_test.py


示例2: test_can_dispatch_soap_request_with_plain_wsgi

 def test_can_dispatch_soap_request_with_plain_wsgi(self):
     dispatcher = SOAPDispatcher(echo_service())
     app = WsgiSoapApplication(dispatcher)
     start_response = self._response_mock()
     soap_message = (
         b'<?xml version="1.0" encoding="utf-8"?>'
         b'<senv:Envelope xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://soap.example/echo/types">'
         b'<senv:Body>'
         b'<ns1:echoRequest xmlns:ns1="http://soap.example/echo/types">'
         b'<value>foobar</value>'
         b'</ns1:echoRequest>'
         b'</senv:Body>'
         b'</senv:Envelope>'
     )
     response = app(self._wsgi_env(soap_message), start_response)
     assert_equals('200 OK', start_response.code)
     assert_equals('text/xml', dict(start_response.headers)['Content-Type'])
     expected_xml = (
         b'<ns0:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/">'
         b'<ns0:Body>'
         b'<ns0:echoResponse xmlns:ns0="http://soap.example/echo/types">'
         b'<value>foobar</value>'
         b'</ns0:echoResponse>'
         b'</ns0:Body>'
         b'</ns0:Envelope>'
     )
     assert_equals(expected_xml, b''.join(response))
开发者ID:FlightDataServices,项目名称:soapfish,代码行数:27,代码来源:wsgi_soap_application_test.py


示例3: test_can_reject_malformed_xml_soap_message

 def test_can_reject_malformed_xml_soap_message(self):
     request = SOAPRequest(dict(SOAPACTION='echo', REQUEST_METHOD='POST'), 'garbage')
     dispatcher = SOAPDispatcher(echo_service())
     response = dispatcher.dispatch(request)
     assert_equals(500, response.http_status_code)
     assert_equals('text/xml', response.http_headers['Content-Type'])
     self.assert_is_soap_fault(response, partial_fault_string=u"Start tag expected, '<' not found")
开发者ID:pricez,项目名称:soapfish,代码行数:7,代码来源:soap_dispatcher_test.py


示例4: test_can_include_imported_schemas_during_validation

 def test_can_include_imported_schemas_during_validation(self):
     # In case the SOAPDispatcher would not use imported schemas for
     # validation it would fail because the 'code' tag is only defined in
     # the imported schema
     handler, handler_state = echo_handler()
     service = echo_service(handler)
     class CodeType(xsd.String):
         pattern = r'[0-9]{5}'
     class Container(xsd.ComplexType):
         value = xsd.Element(CodeType)
     code_schema = xsd.Schema('http://soap.example/included',
         location='http://soap.example/included',
         elementFormDefault=xsd.ElementFormDefault.UNQUALIFIED,
         simpleTypes=[CodeType],
         complexTypes=[Container],
         elements={'foo': xsd.Element(Container)},
     )
     service.methods[0].input = 'foo'
     service.schema.imports = (code_schema, )
     # The setup is a bit simplistic because the <code> tag is not parsed
     # into a soapfish model element for the handler but this was enough
     # to trigger the bug
     dispatcher = SOAPDispatcher(service)
     wsgi_environ = dict(SOAPACTION='echo', REQUEST_METHOD='POST')
     soap_message = '<ns0:foo xmlns:ns0="http://soap.example/included"><value>12345</value></ns0:foo>'
     request = SOAPRequest(wsgi_environ, self._wrap_with_soap_envelope(soap_message))
     response = dispatcher.dispatch(request)
     self.assert_is_successful_response(response, handler_state)
     assert_equals('12345', handler_state.input_.value)
开发者ID:pricez,项目名称:soapfish,代码行数:29,代码来源:soap_dispatcher_test.py


示例5: test_can_dispatch_good_soap_message

    def test_can_dispatch_good_soap_message(self):
        handler, handler_state = echo_handler()
        dispatcher = SOAPDispatcher(echo_service(handler))
        soap_message = ('<ns1:echoRequest xmlns:ns1="http://soap.example/echo/types">'
            '<value>foobar</value>'
        '</ns1:echoRequest>')
        request_message = self._wrap_with_soap_envelope(soap_message)
        request = SOAPRequest(dict(SOAPACTION='echo', REQUEST_METHOD='POST'), request_message)

        response = dispatcher.dispatch(request)
        self.assert_is_successful_response(response, handler_state)
        assert_equals('foobar', handler_state.input_.value)

        response_document = etree.fromstring(response.http_content)
        response_xml = etree.tostring(response_document, pretty_print=True)
        expected_xml = (
            b'<ns0:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/">\n'
            b'  <ns0:Body>\n'
            b'    <ns0:echoResponse xmlns:ns0="http://soap.example/echo/types">\n'
            b'      <value>foobar</value>\n'
            b'    </ns0:echoResponse>\n'
            b'  </ns0:Body>\n'
            b'</ns0:Envelope>\n'
        )
        assert_equals(expected_xml, response_xml)
开发者ID:pricez,项目名称:soapfish,代码行数:25,代码来源:soap_dispatcher_test.py


示例6: test_can_reject_invalid_action

 def test_can_reject_invalid_action(self):
     soap_message = ('<ns1:echoRequest xmlns:ns1="http://soap.example/echo/types">'
         '<value>foobar</value>'
         '</ns1:echoRequest>')
     request_message = self._wrap_with_soap_envelope(soap_message)
     request = SOAPRequest(dict(SOAPACTION='invalid', REQUEST_METHOD='POST'), request_message)
     dispatcher = SOAPDispatcher(echo_service())
     response = dispatcher.dispatch(request)
     self.assert_is_soap_fault(response, partial_fault_string=u"Invalid soap action 'invalid'")
开发者ID:pricez,项目名称:soapfish,代码行数:9,代码来源:soap_dispatcher_test.py


示例7: test_can_reject_non_soap_xml_body

    def test_can_reject_non_soap_xml_body(self):
        request = SOAPRequest(dict(SOAPACTION='echo', REQUEST_METHOD='POST'), '<some>xml</some>')
        dispatcher = SOAPDispatcher(echo_service())

        # previously this raised an AttributeError due to an unhandled exception
        response = dispatcher.dispatch(request)
        assert_equals(500, response.http_status_code)
        assert_equals('text/xml', response.http_headers['Content-Type'])
        self.assert_is_soap_fault(response, partial_fault_string=u'Missing SOAP body')
开发者ID:pricez,项目名称:soapfish,代码行数:9,代码来源:soap_dispatcher_test.py


示例8: test_can_dispatch_requests_based_on_soap_body

 def test_can_dispatch_requests_based_on_soap_body(self):
     handler, handler_state = echo_handler()
     dispatcher = SOAPDispatcher(echo_service(handler))
     soap_message = ('<ns1:echoRequest xmlns:ns1="http://soap.example/echo/types">'
         '<value>foobar</value>'
     '</ns1:echoRequest>')
     request_message = self._wrap_with_soap_envelope(soap_message)
     request = SOAPRequest(dict(SOAPACTION='""', REQUEST_METHOD='POST'), request_message)
     response = dispatcher.dispatch(request)
     self.assert_is_successful_response(response, handler_state)
开发者ID:pricez,项目名称:soapfish,代码行数:10,代码来源:soap_dispatcher_test.py


示例9: test_can_handle_empty_output_header

 def test_can_handle_empty_output_header(self):
     handler, handler_state = echo_handler()
     dispatcher = SOAPDispatcher(echo_service(handler, output_header=EchoOutputHeader))
     soap_message = ('<tns:echoRequest xmlns:tns="http://soap.example/echo/types">'
         '<value>foobar</value>'
     '</tns:echoRequest>')
     request_message = self._wrap_with_soap_envelope(soap_message)
     request = SOAPRequest(dict(SOAPACTION='echo', REQUEST_METHOD='POST'), request_message)
     response = dispatcher.dispatch(request)
     self.assert_is_successful_response(response, handler_state)
开发者ID:pricez,项目名称:soapfish,代码行数:10,代码来源:soap_dispatcher_test.py


示例10: test_evaluate_service_location

 def test_evaluate_service_location(self):
     handler, _ = echo_handler()
     service = echo_service(handler)
     service.location = '{scheme}://{host}/ws'
     dispatcher = SOAPDispatcher(service)
     request = SOAPRequest(dict(REQUEST_METHOD='GET', QUERY_STRING='wsdl',
                                HTTP_HOST='soap.example'), '')
     response = dispatcher.dispatch(request)
     self.assert_is_successful_response(response)
     assert_not_contains('{scheme}', response.http_content.decode())
     assert_not_contains('{http}', response.http_content.decode())
开发者ID:pricez,项目名称:soapfish,代码行数:11,代码来源:soap_dispatcher_test.py


示例11: test_can_validate_soap_header

 def test_can_validate_soap_header(self):
     handler, handler_state = echo_handler()
     dispatcher = SOAPDispatcher(echo_service(handler, input_header=EchoInputHeader))
     soap_header = ('<tns:invalid>42</tns:invalid>')
     soap_message = ('<tns:echoRequest>'
         '<value>foobar</value>'
     '</tns:echoRequest>')
     request_message = self._wrap_with_soap_envelope(soap_message, header=soap_header)
     request = SOAPRequest(dict(SOAPACTION='echo', REQUEST_METHOD='POST'), request_message)
     response = dispatcher.dispatch(request)
     self.assert_is_soap_fault(response, partial_fault_string="DocumentInvalid")
开发者ID:pricez,项目名称:soapfish,代码行数:11,代码来源:soap_dispatcher_test.py


示例12: test_can_validate_soap_message

 def test_can_validate_soap_message(self):
     handler, handler_state = echo_handler()
     dispatcher = SOAPDispatcher(echo_service(handler))
     soap_message = ('<ns1:echoRequest xmlns:ns1="http://soap.example/echo/types">'
         '<invalid>foobar</invalid>'
         '</ns1:echoRequest>')
     request_message = self._wrap_with_soap_envelope(soap_message)
     request = SOAPRequest(dict(SOAPACTION='echo', REQUEST_METHOD='POST'), request_message)
     response = dispatcher.dispatch(request)
     assert_false(handler_state.was_called)
     self.assert_is_soap_fault(response,
         partial_fault_string=u"Element 'invalid': This element is not expected. Expected is ( value ).")
开发者ID:pricez,项目名称:soapfish,代码行数:12,代码来源:soap_dispatcher_test.py


示例13: setUp

 def setUp(self):
     if django is None:
         raise SkipTest('django not installed')
     super(DjangoDispatchTest, self).setUp()
     self.service = echo_service()
     if django.conf.settings.__dict__['_wrapped'] is empty:
         django.conf.settings.configure(self.django_settings())
         django.conf.settings.update(AttrDict(
             ROOT_URLCONF=AttrDict(
                 urlpatterns = patterns('', (r"^ws/$", django_dispatcher(self.service))),
             ),
         ))
     self.client = Client()
开发者ID:Bouke,项目名称:soapfish,代码行数:13,代码来源:django_test.py


示例14: test_can_propagate_custom_input_header

 def test_can_propagate_custom_input_header(self):
     handler, handler_state = echo_handler()
     dispatcher = SOAPDispatcher(echo_service(handler, input_header=EchoInputHeader))
     soap_header = ('<tns:InputVersion>42</tns:InputVersion>')
     soap_message = ('<tns:echoRequest>'
         '<value>foobar</value>'
     '</tns:echoRequest>')
     request_message = self._wrap_with_soap_envelope(soap_message, header=soap_header)
     request = SOAPRequest(dict(SOAPACTION='echo', REQUEST_METHOD='POST'), request_message)
     response = dispatcher.dispatch(request)
     self.assert_is_successful_response(response, handler_state)
     assert_not_none(handler_state.input_header)
     assert_equals('42', handler_state.input_header.InputVersion)
开发者ID:pricez,项目名称:soapfish,代码行数:13,代码来源:soap_dispatcher_test.py


示例15: test_can_handle_xsd_element_as_return_value_from_handler

    def test_can_handle_xsd_element_as_return_value_from_handler(self):
        handler = lambda request, input_: input_
        dispatcher = SOAPDispatcher(echo_service(handler))
        soap_message = ('<ns1:echoRequest xmlns:ns1="http://soap.example/echo/types">'
            '<value>hello</value>'
        '</ns1:echoRequest>')
        request_message = self._wrap_with_soap_envelope(soap_message)
        request = SOAPRequest(dict(SOAPACTION='echo', REQUEST_METHOD='POST'), request_message)

        response = dispatcher.dispatch(request)
        body_text = response.http_content
        if not isinstance(body_text, basestring):
            body_text = body_text.decode('utf-8')
        assert_contains('<value>hello</value>', body_text)
开发者ID:pricez,项目名称:soapfish,代码行数:14,代码来源:soap_dispatcher_test.py


示例16: test_can_propagate_custom_output_header

 def test_can_propagate_custom_output_header(self):
     handler, handler_state = echo_handler()
     def _handler(request, _input):
         resp = handler(request, _input)
         resp.soap_header = EchoOutputHeader(OutputVersion='42')
         return resp
     dispatcher = SOAPDispatcher(echo_service(_handler, output_header=EchoOutputHeader))
     soap_header = ('<tns:InputVersion>42</tns:InputVersion>')
     soap_message = ('<tns:echoRequest xmlns:tns="http://soap.example/echo/types">'
         '<value>foobar</value>'
     '</tns:echoRequest>')
     request_message = self._wrap_with_soap_envelope(soap_message, header=soap_header)
     request = SOAPRequest(dict(SOAPACTION='echo', REQUEST_METHOD='POST'), request_message)
     response = dispatcher.dispatch(request)
     self.assert_is_successful_response(response, handler_state)
     assert_contains(b'<ns0:OutputVersion>42</ns0:OutputVersion>', response.http_content)
开发者ID:pricez,项目名称:soapfish,代码行数:16,代码来源:soap_dispatcher_test.py


示例17: test_can_use_soap_error_from_handler

    def test_can_use_soap_error_from_handler(self):
        soap_error = SOAPError('code', 'internal data error', 'actor')
        faulty_handler = lambda request, input_: SOAPResponse(soap_error)
        dispatcher = SOAPDispatcher(echo_service(handler=faulty_handler))
        soap_message = ('<ns1:echoRequest xmlns:ns1="http://soap.example/echo/types">'
            '<value>foobar</value>'
        '</ns1:echoRequest>')
        request_message = self._wrap_with_soap_envelope(soap_message)
        request = SOAPRequest(dict(REQUEST_METHOD='POST'), request_message)

        response = dispatcher.dispatch(request)
        assert_equals('text/xml', response.http_headers['Content-Type'])
        assert_equals(500, response.http_status_code)
        self.assert_is_soap_fault(response,
            fault_code='code',
            partial_fault_string=u'internal data error'
        )
开发者ID:pricez,项目名称:soapfish,代码行数:17,代码来源:soap_dispatcher_test.py


示例18: test_return_soap_fault_on_exception

 def test_return_soap_fault_on_exception(self):
     def handler(request, _input):
         raise Exception('unexpected exception')
     service = echo_service(handler)
     dispatcher = SOAPDispatcher(service, [ExceptionToSoapFault()])
     soap_message = ('<tns:echoRequest xmlns:tns="http://soap.example/echo/types">'
         '<value>foobar</value>'
     '</tns:echoRequest>')
     request_message = self._wrap_with_soap_envelope(soap_message)
     request = SOAPRequest(dict(SOAPACTION='echo', REQUEST_METHOD='POST'), request_message)
     response = dispatcher.dispatch(request)
     self.assert_is_soap_fault(response,
         fault_code=service.version.Code.SERVER,
         partial_fault_string=u'Internal Error',
     )
     assert_equals('text/xml', response.http_headers['Content-Type'])
     assert_equals(500, response.http_status_code)
开发者ID:pricez,项目名称:soapfish,代码行数:17,代码来源:soap_dispatcher_test.py


示例19: test_hook_soap_response

    def test_hook_soap_response(self):
        message = (
            '<tns:echoRequest xmlns:tns="http://soap.example/echo/types">'
            '<value>Cast a hook to catch a soapfish.</value>'
            '</tns:echoRequest>'
        )
        request = SOAPRequest(
            {'REQUEST_METHOD': 'POST', 'SOAPACTION':'echo'},
            self._wrap_with_soap_envelope(message),
        )

        def hook(dispatcher, request, response):
            response.http_status_code = 999
            return response

        dispatcher = SOAPDispatcher(echo_service(), hooks={'soap-response': hook})
        response = dispatcher.dispatch(request)
        self.assertEqual(response.http_status_code, 999)
开发者ID:FlightDataServices,项目名称:soapfish,代码行数:18,代码来源:soap_dispatcher_test.py


示例20: test_hook_soap_request

    def test_hook_soap_request(self):
        message = (
            '<tns:echoRequest xmlns:tns="http://soap.example/echo/types">'
            '<value>Cast a hook to catch a soapfish.</value>'
            '</tns:echoRequest>'
        )
        request = SOAPRequest(
            {'REQUEST_METHOD': 'POST', 'SOAPACTION':'echo'},
            self._wrap_with_soap_envelope(message),
        )

        def hook(dispatcher, request):
            request.http_content = request.http_content.replace(b'catch', b'snare')
            return request

        dispatcher = SOAPDispatcher(echo_service(), hooks={'soap-request': hook})
        response = dispatcher.dispatch(request)
        self.assertIn(b'Cast a hook to snare a soapfish.', response.http_content)
开发者ID:FlightDataServices,项目名称:soapfish,代码行数:18,代码来源:soap_dispatcher_test.py



注:本文中的soapfish.testutil.echo_service函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python etimport.ElementTree类代码示例发布时间:2022-05-27
下一篇:
Python soap_dispatch.SOAPDispatcher类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap