I'm doing some (isolated) unit test for a view which is decorated with "login_required". Example:
@login_required
def my_view(request):
return HttpResponse('test')
Is it possible to test that the "my_view" function is decorated with "login_required"?
I know I can test the behaviour (anonymous user is redirected to login page) with an integration test (using the test client) but I'd like to do it with an isolated test.
Any idea?
Thanks!
Using
requestslibrary, if you don't pass it a auth cookie you can test that login is required based on whether it returns 401/403/200/whatever