class UserAuthCodeTest(TestCase): def setUp(self): self.encoder = UserAuthCode('secret') self.user = UserFactory(is_active=False) def test_user(self): self.assertIsNotNone(self.user.date_joined) self.assertTrue(self.user.date_joined >= self.user.last_login) def test_salt(self): salt = self.encoder.salt() self.assertEqual(8, len(salt)) def test_auth_code(self): code = self.encoder.auth_code(self.user) self.assertIsNotNone(code) def test_complete_activation(self): code = self.encoder.auth_code(self.user) self.assertTrue(self.encoder.is_valid(self.user, code)) def test_wrong_key(self): self.assertFalse(self.encoder.is_valid(self.user, 'aaa')) def test_already_activated(self): code = self.encoder.auth_code(self.user) self.user.last_login = timezone.now() self.user.save() self.assertFalse(self.encoder.is_valid(self.user, code))
class UserAuthCodeTest(TestCase): def setUp(self): self.encoder = UserAuthCode('secret') self.user = UserFactory(is_active=False) def test_user(self): self.assertIsNotNone(self.user.date_joined) self.assertTrue(self.user.date_joined >= self.user.last_login) def test_salt(self): salt = self.encoder.salt() self.assertEqual(8, len(salt)) def test_auth_code(self): code = self.encoder.auth_code(self.user) self.assertIsNotNone(code) def test_complete_activation(self): code = self.encoder.auth_code(self.user) self.assertTrue(self.encoder.is_valid(self.user, code)) def test_wrong_key(self): self.assertFalse(self.encoder.is_valid(self.user, 'aaa')) def test_already_activated(self): code = self.encoder.auth_code(self.user) self.user.last_login = timezone.now() self.user.save() self.assertFalse(self.encoder.is_valid(self.user, code))
def setUp(self): encoder = UserAuthCode(settings.SECRET_KEY) self.user = UserFactory(is_active=False) self.code = encoder.auth_code(self.user) confirm = EmailTemplate( name='registration confirmation', subject='Account activation', ) confirm.save() complete = EmailTemplate(name='registration complete', ) complete.save()
def setUp(self): encoder = UserAuthCode(settings.SECRET_KEY) self.user = UserFactory(is_active=False) self.code = encoder.auth_code(self.user) confirm = EmailTemplate( name='registration confirmation', subject='Account activation', ) confirm.save() complete = EmailTemplate( name='registration complete', ) complete.save()