Class AsyncRequestFactory
Class that lets you create mock ASGI-like Request objects for use in testing. Usage:
Declaration
source linkDocumentation
rf = AsyncRequestFactory()
get_request = await rf.get('/hello/')
post_request = await rf.post('/submit/', {'foo': 'bar'})
Once you have a request object you can pass it to any view function,
including synchronous ones. The reason we have a separate class here is:
a) this makes ASGIRequest subclasses, and
b) AsyncTestClient can subclass it.
Methods
▶ def generic(self, method, path, data='', content_type='application/octet-stream', ...) override Construct an arbitrary HTTP request.
▶ def request(self, **request) override Construct a generic request object.