class BackendTests(TestCase): """ Tests for LazySignupBackend """ def setUp(self): self.backend = LazySignupBackend() def test_authenticate_no_user(self): """ Test no user exists """ self.assertIsNone(self.backend.authenticate('nobody')) def test_authenticate(self): """ :return: """ user = get_user_model().objects.create_user( username='******', email='*****@*****.**', password='******' ) self.assertEqual( user.email, self.backend.authenticate('admin').email )
def testBackendGetUserAnnotates(self): # Check that the lazysignup backend annotates the user object # with the backend, mirroring what Django's does lazy_view(self.request) backend = LazySignupBackend() pk = User.objects.all()[0].pk self.assertEqual('lazysignup.backends.LazySignupBackend', backend.get_user(pk).backend)
def testBackendGetUserAnnotates(self): # Check that the lazysignup backend annotates the user object # with the backend, mirroring what Django's does lazy_view(self.request) backend = LazySignupBackend() pk = User.objects.all()[0].pk self.assertEqual("lazysignup.backends.LazySignupBackend", backend.get_user(pk).backend)
def test_backend_get_custom_user_class(self): # The get_user method on the backend should also return instances of # the custom user class. lazy_view(self.request) backend = LazySignupBackend() user_class = LazyUser.get_user_class() pk = user_class.objects.all()[0].pk self.assertEqual(user_class, type(backend.get_user(pk)))
def test_backend_get_custom_user_class(self): # The get_user method on the backend should also return instances of # the custom user class. lazy_view(self.request) backend = LazySignupBackend() user_class = LazyUser.get_user_class() pk = user_class.model.objects.all()[0].pk self.assertEqual(user_class, type(backend.get_user(pk)))
def test_backend_get_user_annotates(self): # Check that the lazysignup backend annotates the user object # with the backend, mirroring what Django's does lazy_view(self.request) backend = LazySignupBackend() pk = get_user_model().objects.all()[0].pk self.assertEqual( "lazysignup.backends.LazySignupBackend", backend.get_user(pk).backend )
def test_backend_get_user_annotates(self): # Check that the lazysignup backend annotates the user object # with the backend, mirroring what Django's does lazy_view(self.request) backend = LazySignupBackend() pk = get_user_model().objects.all()[0].pk self.assertEqual( 'lazysignup.backends.LazySignupBackend', backend.get_user(pk).backend )
class BackendTests(TestCase): """ Tests for LazySignupBackend """ def setUp(self): self.backend = LazySignupBackend() def test_authenticate_no_user(self): """ Test no user exists """ self.assertIsNone(self.backend.authenticate('nobody')) def test_authenticate(self): """ :return: """ user = get_user_model().objects.create_user(username='******', email='*****@*****.**', password='******') self.assertEqual(user.email, self.backend.authenticate('admin').email)
def setUp(self): self.backend = LazySignupBackend()