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'
        )
 def faulty_handler(request, input_):
     return SOAPResponse(soap_error)
 def test_constructor(self):
     response = SOAPResponse('', http_status_code=500)
     self.assertEqual(500, response.http_status_code)