Example #1
0
 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'))
Example #2
0
 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'))
Example #3
0
 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
Example #4
0
 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)
Example #5
0
 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)
Example #6
0
 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
Example #7
0
 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)
Example #8
0
 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)