Mock Objects

Mock Requests

This mock allows you to make requests against a view that isn’t included in any URLConf.



rf = RequestFactory()
get_request = rf.get('/hello/')
post_request ='/submit/', {'foo': 'bar'})

This class re-uses the django.test.client.Client interface, docs here:

Once you have a request object you can pass it to any view function, just as if that view had been hooked up using a URLconf.

Original Source

Taken from, originally by Simon Willison.