Clients Return One Value

Currently tempest clients return a response code and body. Since we moved response checking to clients, almost all callers of the clients ignore the response code: Move success response checking to tempest clients. It would be much cleaner if clients returned a single response object that was the body, with a property to get the response status and headers if needed.

Proposed change

Introduce a new ResponseBody class in rest_client:

class ResponseBody(dict):
    Class that wraps an http response and body into a single value.
    Callers that receive this object will normally use it as a dict but
    can extract the response if needed.
    def __init__(self, response, body=None):
        body_data = body or {}
        self.response = response

    def __str__(self):
        body = super.__str__(self)
        return "request: %s\nBody: %s" % (self.response, body)

Change all the tempest clients to return this object and change all the calls to the clients, getting rid of the current ‘_’ for the response.


In theory this could be done in the rest client itself, rather than in each service client, but that would imply much more regularity of the service clients than we have. Also, it would then be necessary to change everything at once because all the tests currently expect two values.

The primary consideration is to not return unused values almost all the time. Another alternative would be to have an argument to the rest client methods that says whether a response should also be returned. I think the current proposal is cleaner.


Unfortunately each client class must be changed lockstep with all calls to that client.


Primary assignees:

David Kranz <>

Other contributors:

Yair Fried <>


Target Milestone for completion:

  • kilo-1

Work Items (for each service client)

  • Change all methods in the tempest clients to return ResponseBody.

  • Change all calls to clients to receive just the response body and check the response code if necessary.