Skip to content

Commit

Permalink
fix: error code changed BAD_REQUEST to FORBIDDEN (#1030)
Browse files Browse the repository at this point in the history
* fix: Error code is changed
In task_comment.py error code changed from BAD_REQUEST to FORBIDDEN for mentorship_relation/relation_id/task/<task_id>/comments

* fix: Error code is changed in dao
In dao/task_comment.py error code return status changed from BAD_REQUEST to FORBIDDEN for mentorship_relation/relation_id/task/<task_id>/comments

* fix: status code has been changes from BAD_REQUEST to FORBIDDEN

* Change from BAD_REQUEST to FORBIDDEN in task.py

Co-authored-by: Isabel Costa <11148726+isabelcosta@users.noreply.github.com>
  • Loading branch information
b-thebest and isabelcosta authored Jul 22, 2021
1 parent 7160aa6 commit c154317
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/api/dao/task_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def validate_data_for_task_comment(user_id, task_id, relation_id):
)

if relation.state != MentorshipRelationState.ACCEPTED:
return messages.UNACCEPTED_STATE_RELATION, HTTPStatus.BAD_REQUEST
return messages.UNACCEPTED_STATE_RELATION, HTTPStatus.FORBIDDEN

task = relation.tasks_list.find_task_by_id(task_id)
if task is None:
Expand Down
2 changes: 1 addition & 1 deletion app/api/resources/task_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class TaskComments(Resource):
)
@task_comment_ns.doc(
responses={
HTTPStatus.BAD_REQUEST.value: f"{messages.UNACCEPTED_STATE_RELATION}",
HTTPStatus.FORBIDDEN.value: f"{messages.UNACCEPTED_STATE_RELATION}",
HTTPStatus.UNAUTHORIZED.value: f"{messages.TOKEN_HAS_EXPIRED}<br>"
f"{messages.TOKEN_IS_INVALID}<br>"
f"{messages.AUTHORISATION_TOKEN_IS_MISSING}<br>"
Expand Down
2 changes: 1 addition & 1 deletion tests/task_comments/test_api_create_task_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_task_comment_creation_api_with_unaccepted_relation(self):
data=json.dumps(dict(comment="comment")),
)

self.assertEqual(HTTPStatus.BAD_REQUEST, actual_response.status_code)
self.assertEqual(HTTPStatus.FORBIDDEN, actual_response.status_code)
self.assertDictEqual(expected_response, json.loads(actual_response.data))

def test_task_comment_creation_api_with_task_not_existing(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/task_comments/test_api_delete_task_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_task_comment_deletion_api_with_unaccepted_relation(self):
content_type="application/json",
)

self.assertEqual(HTTPStatus.BAD_REQUEST, actual_response.status_code)
self.assertEqual(HTTPStatus.FORBIDDEN, actual_response.status_code)
self.assertDictEqual(expected_response, json.loads(actual_response.data))

def test_task_comment_deletion_api_with_task_not_existing(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/task_comments/test_api_get_task_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_task_comment_listing_api_with_unaccepted_relation(self):
content_type="application/json",
)

self.assertEqual(HTTPStatus.BAD_REQUEST, actual_response.status_code)
self.assertEqual(HTTPStatus.FORBIDDEN, actual_response.status_code)
self.assertDictEqual(expected_response, json.loads(actual_response.data))

def test_task_comment_listing_api(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/task_comments/test_api_modify_task_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_task_comment_modification_api_with_unaccepted_relation(self):
data=json.dumps(dict(comment="comment")),
)

self.assertEqual(HTTPStatus.BAD_REQUEST, actual_response.status_code)
self.assertEqual(HTTPStatus.FORBIDDEN, actual_response.status_code)
self.assertDictEqual(expected_response, json.loads(actual_response.data))

def test_task_comment_modification_api_with_task_not_existing(self):
Expand Down

0 comments on commit c154317

Please sign in to comment.