Base HTTP service client
demands.
HTTPServiceClient
(url, **kwargs)¶Bases: requests.sessions.Session
Extendable base service client.
Client can be configured with any param allowed by the requests API. These params will be uses with each and every request and can be overridden with kwargs. demands adds the following params:
Parameters: |
|
---|
is_acceptable
(response, request_params)¶Override this method to create a different definition of what kind of response is acceptable. If bool(the_return_value) is False then an HTTPServiceError will be raised.
For example, you might want to assert that the body must be empty, so you could return len(response.content) == 0.
In the default implementation, a response is acceptable if and only if the response code is either less than 300 (typically 200, i.e. OK) or if it is in the expected_response_codes parameter in the constructor.
post_send
(response, **kwargs)¶Override this method to modify returned response
pre_send
(request_params)¶Override this method to modify sent request parameters
request
(method, path, **kwargs)¶Send a requests.Request
and demand a
requests.Response
demands.
HTTPServiceError
(response)¶Bases: exceptions.AssertionError