def test_valid_signup(self): user = User.signup('tester2','*****@*****.**','password',None) user.id = 100 db.session.commit() found_user = User.query.get(100) self.assertIn(found_user,User.query.all()) self.assertNotEqual(found_user.password,'password') self.assertNotEqual(found_user.password,self.my_tester.password)
def setUp(self): db.drop_all() db.create_all() tester = User.signup('tester','*****@*****.**','password',None) tester.id =1000 db.session.commit() my_tester = User.query.get(1000) self.my_tester = my_tester self.client = app.test_client()
def test_invalid_authenticate(self): invalid_login = User.authenticate('tester','password1') hashed_pass = bcrypt.generate_password_hash('password').decode('UTF-8') invalid_login2 = User.authenticate('tester',hashed_pass) self.assertFalse(invalid_login) self.assertFalse(invalid_login2)
def test_taken_email(self): user = User.signup('tester2','*****@*****.**','password',None) with self.assertRaises(exc.IntegrityError) as context: db.session.commit()
def test_user_model(self): user = User(email='*****@*****.**',username='******',password='******',avatar_url=None) db.session.add(user) db.session.commit() self.assertEqual(len(user.user_lists),0)