예제 #1
0
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
        )
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)))
예제 #5
0
 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)))
예제 #6
0
 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
     )
예제 #7
0
 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
     )
예제 #8
0
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)
예제 #9
0
 def setUp(self):
     self.backend = LazySignupBackend()
예제 #10
0
 def setUp(self):
     self.backend = LazySignupBackend()