def test_crud(self): with app.app_context(): user = UserModel('mahsan', 'm1234') self.assertIsNone(UserModel.find_by_username('mahsan')) self.assertIsNone(UserModel.find_by_id(1)) user.save_to_db() self.assertIsNotNone(UserModel.find_by_username('mahsan')) self.assertIsNotNone(UserModel.find_by_id(1))
def test_crud(self): with self.app_context(): user = UserModel('test', 'abcd') self.assertIsNone(UserModel.find_by_username('test')) self.assertIsNone(UserModel.find_by_id('1')) user.save_to_db() self.assertIsNotNone(UserModel.find_by_username('test')) self.assertIsNotNone(UserModel.find_by_id('1'))
def test_crud(self): with self.app_context(): user = UserModel('test', 'abcd') self.assertIsNone(UserModel.find_by_username('test'), "Failed - user not found") self.assertIsNone(UserModel.find_by_id(1)) user.save_to_db() self.assertIsNotNone(UserModel.find_by_username('test'), "Failed - user not found") self.assertIsNotNone(UserModel.find_by_id(1))
def identity(payload): """ function get called when user already authenticated and flask-jwt verified thier authorization header is correct :param payload: a dictionary with 'identity' key wjich is the user id :return: usermodel object """ user_id = payload['identity'] return UserModel.find_by_id(user_id)
def identity(payload): """ Function that gets called when user has already authenticated, and Flask-JWT verified their authorisation header is correct. :param payload: A dictionary with 'identity' key, which is the user id :return: A UserModel object """ user_id = payload['identity'] return UserModel.find_by_id(user_id)
def identity(payload): ''' Gets called when user has already authenticated ahd Flask-JwT verified the authentication header is correct :param payload: Dict with 'identity', key, which is the user id :return: UserModel object ''' user_id = payload['identity'] return UserModel.find_by_id(user_id)