Exemple #1
0
 def set_up(self):
     fixture_transport = transports.FixtureTransport()
     self.transport = transports.DebugTransport(fixture_transport)
     req = transports.Request()
     req.service = 'SoftLayer_Account'
     req.method = 'getObject'
     self.req = req
Exemple #2
0
    def test_print_reproduceable_post(self):
        req = transports.Request()
        req.url = "https://test.com"
        req.payload = "testing"
        req.transport_headers = {"test-headers": 'aaaa'}
        req.args = 'createObject'

        rest_transport = transports.RestTransport()
        transport = transports.DebugTransport(rest_transport)

        output_text = transport.print_reproduceable(req)

        self.assertIn("https://test.com", output_text)
        self.assertIn("-X POST", output_text)
Exemple #3
0
    def test_error(self, request):
        # Test JSON Error
        e = requests.HTTPError('error')
        e.response = mock.MagicMock()
        e.response.status_code = 404
        e.response.text = '''{
            "error": "description",
            "code": "Error Code"
        }'''
        request().raise_for_status.side_effect = e

        req = transports.Request()
        req.service = 'SoftLayer_Service'
        req.method = 'Resource'
        rest_transport = transports.RestTransport()
        transport = transports.DebugTransport(rest_transport)
        self.assertRaises(SoftLayer.SoftLayerAPIError, transport, req)
        calls = transport.get_last_calls()
        self.assertEqual(404, calls[0].exception.faultCode)