Esempio n. 1
0
 def test_valid_confirmation_token(self):
     """Test a valid email confirmation token"""
     usr = User(password='******')
     db.session.add(usr)
     db.session.commit()
     token = usr.generate_confirmation_token()
     self.assertTrue(usr.confirm(token))
Esempio n. 2
0
 def test_expired_confirmation_token(self):
     """Test that an expired email confirmation token fails"""
     usr = User(password='******')
     db.session.add(usr)
     db.session.commit()
     token = usr.generate_confirmation_token(1)
     time.sleep(2)
     self.assertFalse(usr.confirm(token))
Esempio n. 3
0
 def test_invalid_confirmation_token(self):
     """Test that a wrongly created email confirmation token fails"""
     usr1 = User(password='******')
     usr2 = User(password='******')
     db.session.add(usr1)
     db.session.add(usr2)
     db.session.commit()
     token = usr1.generate_confirmation_token()
     self.assertFalse(usr2.confirm(token))