Skip to content

Commit

Permalink
fix: complete task API http response code (#1050)
Browse files Browse the repository at this point in the history
* Fix: refactor HTTP error codes PUT /mentorship_relation/{request_id}/task/{task_id}/complete

* updated status code in tests
  • Loading branch information
vj-codes authored Mar 27, 2021
1 parent 31a170c commit 8f8ae21
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/api/dao/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def complete_task(user_id: int, mentorship_relation_id: int, task_id: int):
return messages.TASK_DOES_NOT_EXIST, HTTPStatus.NOT_FOUND

if task.get("is_done"):
return messages.TASK_WAS_ALREADY_ACHIEVED, HTTPStatus.FORBIDDEN
return messages.TASK_WAS_ALREADY_ACHIEVED, HTTPStatus.CONFLICT
else:
relation.tasks_list.update_task(
task_id=task_id,
Expand Down
2 changes: 1 addition & 1 deletion app/api/resources/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class UpdateTask(Resource):
@task_ns.doc("update_task_in_mentorship_relation")
@task_ns.expect(auth_header_parser)
@task_ns.response(HTTPStatus.OK, f"{messages.TASK_WAS_ACHIEVED_SUCCESSFULLY}")
@task_ns.response(HTTPStatus.BAD_REQUEST, f"{messages.TASK_WAS_ALREADY_ACHIEVED}")
@task_ns.response(HTTPStatus.CONFLICT, f"{messages.TASK_WAS_ALREADY_ACHIEVED}")
@task_ns.response(
HTTPStatus.UNAUTHORIZED,
f"{messages.TOKEN_HAS_EXPIRED}\n"
Expand Down
2 changes: 1 addition & 1 deletion tests/tasks/test_dao_complete_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_achieve_achieved_task(self):

expected_response = (
messages.TASK_WAS_ALREADY_ACHIEVED,
HTTPStatus.FORBIDDEN,
HTTPStatus.CONFLICT,
)
actual_response = TaskDAO.complete_task(
self.first_user.id, self.mentorship_relation_w_second_user.id, 2
Expand Down

0 comments on commit 8f8ae21

Please sign in to comment.