Skip to content

Commit

Permalink
Reverting back wrong changes
Browse files Browse the repository at this point in the history
  • Loading branch information
carlomorelli committed May 4, 2018
1 parent 5f59807 commit 1329283
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
26 changes: 13 additions & 13 deletions src/acrewstic.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ def get_task(task_id):

@app.route('/acrewstic/tasks', methods=['POST'])
def create_task():
if not request.json() or 'title' not in request.json():
if not request.get_json() or 'title' not in request.get_json():
abort(400)
task = {
'id': tasks[-1]['id'] + 1,
'title': request.json()['title'],
'description': request.json().get('description', default=''),
'title': request.get_json()['title'],
'description': request.get_json().get('description', ''),
'done': False
}
tasks.append(task)
Expand All @@ -66,20 +66,20 @@ def update_task(task_id):
task = [task for task in tasks if task['id'] == task_id]
if len(task) == 0:
abort(404)
if not request.json():
if not request.get_json():
abort(400)
if 'title' in request.json():
if type(request.json()['title']) is not str:
if 'title' in request.get_json():
if type(request.get_json()['title']) is not str:
abort(400)
if 'description' in request.json():
if type(request.json()['description']) is not str:
if 'description' in request.get_json():
if type(request.get_json()['description']) is not str:
abort(400)
if 'done' in request.json():
if type(request.json()['done']) is not bool:
if 'done' in request.get_json():
if type(request.get_json()['done']) is not bool:
abort(400)
task[0]['title'] = request.json().get('title', default=task[0]['title'])
task[0]['description'] = request.json().get('description', default=task[0]['description'])
task[0]['done'] = request.json().get('done', default=task[0]['done'])
task[0]['title'] = request.get_json().get('title', task[0]['title'])
task[0]['description'] = request.get_json().get('description', task[0]['description'])
task[0]['done'] = request.get_json().get('done', task[0]['done'])
return jsonify({'task': task[0]})


Expand Down
4 changes: 3 additions & 1 deletion test/test_rest_api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import json

import mock
from src.acrewstic import app
import mockredis

from src.acrewstic import app


class TestRestApi:

Expand Down

0 comments on commit 1329283

Please sign in to comment.