API¶
-
class
async_responses.Response(method, hostname, path, handler, status)¶
-
class
async_responses.Call(method, url, args, kwargs)¶
-
class
async_responses.AsyncResponses(*, mock_module=None, passthrough=[])¶ Async Responses context manager
- Parameters
passthrough – list of patterns of URLs which won’t be mocked
mock_module – mock module, defaults to unittest.mock
-
add(method, hostname, path, handler, status=200)¶ Mocks aiohttp response for the next request matching parameters.
- Parameters
method (
str) – HTTP method, for examplegethostname (
str) – server hostnamepath (
str) – pathhandler (
Union[Callable,dict,str,Exception]) – response, can be either a dict, string, callable or an exceptionstatus (
int) – status code, defaults to 200
-
property
calls¶ List of calls
- Return type
List[Call]
-
get(hostname, path, handler, status=200)¶ Mocks GET request. Shorthand for
add('get', *args)- Return type
None
-
passthrough(pattern)¶ Adds passthrough. Requests to URLs which match the pattern won’t be mocked.
- Return type
None
-
patch(hostname, path, handler, status=200)¶ Mocks PATCH request. Shorthand for
add('patch', *args)- Return type
None
-
post(hostname, path, handler, status=200)¶ Mocks POST request. Shorthand for
add('post', *args)- Return type
None
-
put(hostname, path, handler, status=200)¶ Mocks PUT request. Shorthand for
add('put', *args)- Return type
None
-
reset()¶ Resets mock
- Return type
None
-
property
responses¶ List of responses
- Return type
List[Response]