Ejemplo n.º 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
        )
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)))
Ejemplo n.º 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)))
Ejemplo n.º 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
     )
Ejemplo n.º 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
     )
Ejemplo n.º 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)
Ejemplo n.º 9
0
 def setUp(self):
     self.backend = LazySignupBackend()
Ejemplo n.º 10
0
 def setUp(self):
     self.backend = LazySignupBackend()