def test_normal(self): func = login_required(self.f) response = func(self.request) assert not self.f.called eq_(response.status_code, 302) eq_(response['Location'], '%s?to=%s' % (reverse('users.login'), 'path'))
def test_no_redirect_success(self): func = login_required(redirect=False)(self.f) self.request.user.is_authenticated.return_value = True func(self.request) assert self.f.called
def test_decorator_syntax(self): # @login_required(redirect=False) func = login_required(redirect=False)(self.f) response = func(self.request) assert not self.f.called eq_(response.status_code, 401)
def test_no_redirect(self): func = login_required(self.f, redirect=False) response = func(self.request) assert not self.f.called eq_(response.status_code, 401)