def getUserById(uid):
     try:
         user = User.getUserById(uid)
         if user:
             user_dict = to_dict(user)
             result = {"message": "Success!", "user": user_dict}
             return jsonify(result), HttpStatus.OK
         else:
             return jsonify(
                 reason="User does not exist."), HttpStatus.NOT_FOUND
     except Exception as e:
         return jsonify(reason="Server error",
                        error=e.__str__()), HttpStatus.INTERNAL_SERVER_ERROR
Exemplo n.º 2
0
 def test_get_user_by_id(self):
     data = {'email': 'test', 'password': '******', 'username': '******'}
     user = User(**data).create()
     result = User.getUserById(user.user_id)
     assert user == result