def test_check_password(self): with mock_user() as user: full_user = db.get_user_by_id(user['id']) self.assertTrue(db.check_password(user['password'], full_user['password_hash'])) self.assertFalse(db.check_password(random_string(10), full_user['password_hash']))
def test_change_password(self): with mock_user() as user: new_password = random_string(20) db.change_user_password( user_id=user['id'], password=new_password) full_user = db.get_user_by_id(user['id']) self.assertTrue(db.check_password(new_password, full_user['password_hash']))
def test_delete_user(self): with mock_user() as user: db.delete_user(user['id']) self.assertFalse(db.get_user_by_id(user['id']))
def test_get_user_by_id(self): with mock_user() as user: result = db.get_user_by_id(user['id']) self.assertEqual(result['id'], user['id']) self.assertEqual(result['email'], user['email'])