Example #1
0
 def setUp(self):
     self.user = UserFactory.build(
         email='*****@*****.**',
     )
     self.user.set_password('test')
     self.user.save()
     self.auth = EmailAuthBackend()
Example #2
0
class EmailBackendTest(TestCase):
    def setUp(self):
        self.user = UserFactory.build(
            email='*****@*****.**',
        )
        self.user.set_password('test')
        self.user.save()
        self.auth = EmailAuthBackend()

    def tearDown(self):
        self.user.delete()

    def test_authenticate(self):
        user = self.auth.authenticate(
            username='******', password='******')
        self.assertIsNotNone(user)
        self.assertEqual(user, self.user)

    def test_wrong_username(self):
        user = self.auth.authenticate(
            username='******', password='******')
        self.assertIsNone(user)

    def test_get_user(self):
        user = self.auth.get_user(self.user.pk)
        self.assertEqual(user, self.user)

    def test_wrong_id(self):
        user = self.auth.get_user(self.user.pk + 1)
        self.assertIsNone(user)