Ejemplo n.º 1
0
 def test_soap_envelope(self):
     """
     `soap_envelope` wraps content in a SOAP envelope element.
     """
     self.assertEqual(
         '<soapenv:Envelope xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>'
         'hello</soapenv:Body></soapenv:Envelope>',
         tostring(soap_envelope('hello')))
     self.assertEqual(
         '<soapenv:Envelope xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>'
         '<tag>hello</tag></soapenv:Body></soapenv:Envelope>',
         tostring(soap_envelope(Element('tag', 'hello'))))
Ejemplo n.º 2
0
 def test_soap_envelope(self):
     """
     `soap_envelope` wraps content in a SOAP envelope element.
     """
     self.assertEqual(
         '<soapenv:Envelope xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>'
         'hello</soapenv:Body></soapenv:Envelope>',
         tostring(soap_envelope('hello')))
     self.assertEqual(
         '<soapenv:Envelope xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>'
         '<tag>hello</tag></soapenv:Body></soapenv:Envelope>',
         tostring(soap_envelope(Element('tag', 'hello'))))
Ejemplo n.º 3
0
 def test_unwrap_soap_envelope_header(self):
     """
     `unwrap_soap_envelope` unwraps a SOAP envelope element, with a header,
     to a tuple of the SOAP body and header elements.
     """
     body, header = unwrap_soap_envelope(
         soap_envelope(Element('tag', 'hello'), Element('header', 'value')))
     self.assertEqual(
         '<soapenv:Header xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/">'
         '<header>value</header></soapenv:Header>', tostring(header))
     self.assertEqual(
         '<soapenv:Body xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/">'
         '<tag>hello</tag></soapenv:Body>', tostring(body))
Ejemplo n.º 4
0
 def test_unwrap_soap_envelope_header(self):
     """
     `unwrap_soap_envelope` unwraps a SOAP envelope element, with a header,
     to a tuple of the SOAP body and header elements.
     """
     body, header = unwrap_soap_envelope(
         soap_envelope(
             Element('tag', 'hello'),
             Element('header', 'value')))
     self.assertEqual(
         '<soapenv:Header xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/">'
         '<header>value</header></soapenv:Header>',
         tostring(header))
     self.assertEqual(
         '<soapenv:Body xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/">'
         '<tag>hello</tag></soapenv:Body>',
         tostring(body))
Ejemplo n.º 5
0
 def test_soap_fault(self):
     """
     `soap_fault` constructs a SOAP fault element from a code and
     description.
     """
     self.assertEqual(
         '<soapenv:Fault xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/">'
         '<faultcode>soapenv:Client</faultcode>'
         '<faultstring>Oops.</faultstring></soapenv:Fault>',
         tostring(soap_fault('soapenv:Client', 'Oops.')))
Ejemplo n.º 6
0
 def test_response_no_body(self):
     """
     `perform_soap_request` raises `SoapFault` if the response contains no
     SOAP body element..
     """
     response = MockResponse(http.OK, tostring(SOAP_ENV.Envelope('hello')))
     f = self.failureResultOf(
         self._perform_soap_request(response, 'uri', 'action', 'request'),
         SoapFault)
     self.assertEqual('soapenv:Client', f.value.code)
     self.assertEqual('Malformed SOAP request', f.getErrorMessage())
Ejemplo n.º 7
0
 def test_soap_fault(self):
     """
     `soap_fault` constructs a SOAP fault element from a code and
     description.
     """
     self.assertEqual(
         '<soapenv:Fault xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/">'
         '<faultcode>soapenv:Client</faultcode>'
         '<faultstring>Oops.</faultstring></soapenv:Fault>',
         tostring(soap_fault('soapenv:Client', 'Oops.')))
Ejemplo n.º 8
0
 def test_response_no_body(self):
     """
     `perform_soap_request` raises `SoapFault` if the response contains no
     SOAP body element..
     """
     response = MockResponse(http.OK, tostring(SOAP_ENV.Envelope('hello')))
     f = self.failureResultOf(
         self._perform_soap_request(response, 'uri', 'action', 'request'),
         SoapFault)
     self.assertEqual('soapenv:Client', f.value.code)
     self.assertEqual('Malformed SOAP request', f.getErrorMessage())
Ejemplo n.º 9
0
 def test_unwrap_soap_envelope(self):
     """
     `unwrap_soap_envelope` unwraps a SOAP envelope element, with no header,
     to a tuple of the SOAP body element and ``None``.
     """
     body, header = unwrap_soap_envelope(
         soap_envelope(Element('tag', 'hello')))
     self.assertIdentical(None, header)
     self.assertEqual(
         '<soapenv:Body xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/"><tag>hello</tag>'
         '</soapenv:Body>', tostring(body))
Ejemplo n.º 10
0
 def test_unwrap_soap_envelope(self):
     """
     `unwrap_soap_envelope` unwraps a SOAP envelope element, with no header,
     to a tuple of the SOAP body element and ``None``.
     """
     body, header = unwrap_soap_envelope(
         soap_envelope(Element('tag', 'hello')))
     self.assertIdentical(None, header)
     self.assertEqual(
         '<soapenv:Body xmlns:soapenv='
         '"http://schemas.xmlsoap.org/soap/envelope/"><tag>hello</tag>'
         '</soapenv:Body>',
         tostring(body))
Ejemplo n.º 11
0
 def test_success(self):
     """
     `perform_soap_request` issues a SOAP request, over HTTP, to a URI, sets
     the ``SOAPAction`` header and parses the response as a SOAP envelope.
     """
     response = MockResponse.build(http.OK, 'response', 'response_header')
     body, header = self.successResultOf(
         self._perform_soap_request(response, 'uri', 'action', 'request'))
     self.assertEqual([('uri', tostring(soap_envelope('request')), {
         'SOAPAction': 'action',
         'Content-Type': 'text/xml; charset="utf-8"'
     })], self.requests)
     self.assertEqual(SOAP_ENV.Body.text, body.tag)
     self.assertEqual('response', body.text)
     self.assertEqual(SOAP_ENV.Header.text, header.tag)
     self.assertEqual('response_header', header.text)
Ejemplo n.º 12
0
 def test_success(self):
     """
     `perform_soap_request` issues a SOAP request, over HTTP, to a URI, sets
     the ``SOAPAction`` header and parses the response as a SOAP envelope.
     """
     response = MockResponse.build(http.OK, 'response', 'response_header')
     body, header = self.successResultOf(
         self._perform_soap_request(response, 'uri', 'action', 'request'))
     self.assertEqual([
         ('uri',
          tostring(soap_envelope('request')),
          {'SOAPAction': 'action',
           'Content-Type': 'text/xml; charset="utf-8"'})],
         self.requests)
     self.assertEqual(SOAP_ENV.Body.text, body.tag)
     self.assertEqual('response', body.text)
     self.assertEqual(SOAP_ENV.Header.text, header.tag)
     self.assertEqual('response_header', header.text)