def testUnwrapSoapException(self): transport = SoapHttpTransport() transport.transport = MockTransport() str = """<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <context xmlns="urn:zimbra"/> </soap:Header> <soap:Body> <soap:Fault> <soap:faultcode>soap:CODE</soap:faultcode> <soap:faultstring>MESSAGE</soap:faultstring> <soap:detail> <Error xmlns="urn:zimbra"> <Code>CODE</Code> <Trace>TRACE</Trace> </Error> </soap:detail> </soap:Fault> </soap:Body> </soap:Envelope> """ def read(): return str exc = urllib2.HTTPError('url', '500', 'message', None, None) exc.read = read result = transport.init_soap_exception(exc) self.assertEqual('soap:CODE:MESSAGE', result.message) self.assertEqual('CODE', result.code) self.assertEqual('TRACE', result.trace)
def testInitSoapException(self): transport = SoapHttpTransport() result = transport.init_soap_exception(ValueError()) self.assertEqual(None, result.code) self.assertEqual(None, result.trace)