aboutsummaryrefslogtreecommitdiff
path: root/src/lb_app/api.py
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-19 13:10:04 +0200
committerneodarz <neodarz@neodarz.net>2018-08-19 13:10:04 +0200
commit2a9518c9e771c9eec67aa25ee0d1e2e8b8195892 (patch)
tree46dc7d03c50d1c776e45a5d5a2580ffa8115e4df /src/lb_app/api.py
parent7867863b6cd21a87b97df7cabd6871f6a5204602 (diff)
downloadliberationCenter-master.tar.xz
liberationCenter-master.zip
Use status code instead of simple message for testingHEADmaster
Diffstat (limited to '')
-rw-r--r--src/lb_app/api.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lb_app/api.py b/src/lb_app/api.py
index 9827828..9ac2bef 100644
--- a/src/lb_app/api.py
+++ b/src/lb_app/api.py
@@ -27,7 +27,11 @@ user_model = api.model('User', {
class Users(Resource):
def get(self):
""" Get user list """
- return loads(dumps(user.all()))
+ users = loads(dumps(user.all()))
+ if not users:
+ return loads('{"msg": "No users"}'), 404
+ print(users)
+ return loads(dumps(user.all())), 200
@api.route('/user/register')
@@ -38,9 +42,7 @@ class Register(Resource):
args = request.get_json(force=True)
status = user.register(args.get('username'))
- if status is None:
- return loads('{"msg": "done"}'), 201
- return loads('{"msg": "'+status+'"}'), 200
+ return loads('{"msg": "'+status['msg']+'"}'), status['code']
@api.route('/users/<username>')
@api.doc(params={'username': 'Jean'})
@@ -49,6 +51,4 @@ class Remove(Resource):
""" Remove a user """
status = user.remove(username)
- if status is None:
- return loads('{"msg": "done"}'), 201
- return loads('{"msg": "'+status+'"}'), 200
+ return loads('{"msg": "'+status['msg']+'"}'), status['code']