def setUp(self): self.app = create_app(testing=True) self.app_context = self.app.app_context() self.app_context.push() db.create_all() # Create a test user usr = Users(email='*****@*****.**', username='******') usr.set_password('testpass') db.session.add(usr) db.session.commit() self.user = usr
def test_new_user(self): usr = Users( email='*****@*****.**', username='******', ) usr.set_password('cat') db.session.add(usr) db.session.commit() self.assertTrue(usr.username is not None) self.assertTrue(usr.email is not None) self.assertTrue(usr.passwd_digest is not None) self.assertTrue(isinstance(usr.joined_on, datetime))
def test_password_salts_are_random(self): u = Users(username='******') u.set_password('cat') u2 = Users(username='******') u2.set_password('cat') self.assertTrue(u.passwd_digest != u2.passwd_digest)
def setUp(self): self.app = create_app(testing=True) self.app_context = self.app.app_context() self.app_context.push() db.create_all() self.client = self.app.test_client() self.baseURL = '/api/v1' # Create a test user usr = Users(email='*****@*****.**', username='******') usr.set_password('testpass') db.session.add(usr) db.session.commit() self.user = usr # Setup a bearer token with self.app_context: self.token = create_access_token(self.user.id)
def make_user(self, data): return Users(**data)
def test_password_verification(self): u = Users(username='******') u.set_password('cat') self.assertTrue(u.check_password('cat')) self.assertFalse(u.check_password('dog'))
def test_password_setter(self): u = Users(username='******') u.set_password('cat') self.assertTrue(u.passwd_digest is not None)