コード例 #1
0
ファイル: test_server.py プロジェクト: musabaloyi/vumi
    def test_render_soap_fault(self):
        """
        `SmsNotificationService.render_POST` logs any exceptions that occur
        during processing and writes a SOAP fault back to the request. If the
        logged exception is a `SoapFault` its ``to_element`` method is invoked
        to serialize the fault.
        """
        service = SmsNotificationService(None, None)
        service.process = lambda *a, **kw: L.done()
        request = DummyRequest([])
        request.content = StringIO(tostring(L.hello()))
        d = request.notifyFinish()

        service.render_POST(request)
        self.successResultOf(d)
        self.assertEqual(http.INTERNAL_SERVER_ERROR, request.responseCode)
        failures = self.flushLoggedErrors(SoapFault)
        self.assertEqual(1, len(failures))
        self.assertEqual(
            {
                str(SOAP_ENV.Envelope): {
                    str(SOAP_ENV.Body): {
                        str(SOAP_ENV.Fault): {
                            'faultcode': 'soapenv:Client',
                            'faultstring': 'Malformed SOAP request'
                        }
                    }
                }
            }, element_to_dict(fromstring(''.join(request.written))))
コード例 #2
0
ファイル: test_server.py プロジェクト: AndrewCvekl/vumi
    def test_render_soap_fault(self):
        """
        `SmsNotificationService.render_POST` logs any exceptions that occur
        during processing and writes a SOAP fault back to the request. If the
        logged exception is a `SoapFault` its ``to_element`` method is invoked
        to serialize the fault.
        """
        service = SmsNotificationService(None, None)
        service.process = lambda *a, **kw: L.done()
        request = DummyRequest([])
        request.content = StringIO(tostring(L.hello()))
        d = request.notifyFinish()

        service.render_POST(request)
        self.successResultOf(d)
        self.assertEqual(http.INTERNAL_SERVER_ERROR, request.responseCode)
        failures = self.flushLoggedErrors(SoapFault)
        self.assertEqual(1, len(failures))
        self.assertEqual(
            {str(SOAP_ENV.Envelope): {
                str(SOAP_ENV.Body): {
                    str(SOAP_ENV.Fault): {
                        'faultcode': 'soapenv:Client',
                        'faultstring': 'Malformed SOAP request'}}}},
            element_to_dict(fromstring(''.join(request.written))))
コード例 #3
0
ファイル: test_server.py プロジェクト: AndrewCvekl/vumi
 def test_render(self):
     """
     `SmsNotificationService.render_POST` parses a SOAP request and
     dispatches it to `SmsNotificationService.process` for processing.
     """
     service = SmsNotificationService(None, None)
     service.process = lambda *a, **kw: L.done()
     request = DummyRequest([])
     request.content = StringIO(tostring(soap_envelope('hello')))
     d = request.notifyFinish()
     service.render_POST(request)
     self.successResultOf(d)
     self.assertEqual(http.OK, request.responseCode)
     self.assertEqual(
         {str(SOAP_ENV.Envelope): {
             str(SOAP_ENV.Body): {
                 'done': None}}},
         element_to_dict(fromstring(''.join(request.written))))
コード例 #4
0
ファイル: test_server.py プロジェクト: musabaloyi/vumi
 def test_render(self):
     """
     `SmsNotificationService.render_POST` parses a SOAP request and
     dispatches it to `SmsNotificationService.process` for processing.
     """
     service = SmsNotificationService(None, None)
     service.process = lambda *a, **kw: L.done()
     request = DummyRequest([])
     request.content = StringIO(tostring(soap_envelope('hello')))
     d = request.notifyFinish()
     service.render_POST(request)
     self.successResultOf(d)
     self.assertEqual(http.OK, request.responseCode)
     self.assertEqual(
         {str(SOAP_ENV.Envelope): {
              str(SOAP_ENV.Body): {
                  'done': None
              }
          }}, element_to_dict(fromstring(''.join(request.written))))