Skip to content

Commit c154317

Browse files
fix: error code changed BAD_REQUEST to FORBIDDEN (#1030)
* 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 <[email protected]>
1 parent 7160aa6 commit c154317

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

app/api/dao/task_comment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def validate_data_for_task_comment(user_id, task_id, relation_id):
1919
)
2020

2121
if relation.state != MentorshipRelationState.ACCEPTED:
22-
return messages.UNACCEPTED_STATE_RELATION, HTTPStatus.BAD_REQUEST
22+
return messages.UNACCEPTED_STATE_RELATION, HTTPStatus.FORBIDDEN
2323

2424
task = relation.tasks_list.find_task_by_id(task_id)
2525
if task is None:

app/api/resources/task_comment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class TaskComments(Resource):
146146
)
147147
@task_comment_ns.doc(
148148
responses={
149-
HTTPStatus.BAD_REQUEST.value: f"{messages.UNACCEPTED_STATE_RELATION}",
149+
HTTPStatus.FORBIDDEN.value: f"{messages.UNACCEPTED_STATE_RELATION}",
150150
HTTPStatus.UNAUTHORIZED.value: f"{messages.TOKEN_HAS_EXPIRED}<br>"
151151
f"{messages.TOKEN_IS_INVALID}<br>"
152152
f"{messages.AUTHORISATION_TOKEN_IS_MISSING}<br>"

tests/task_comments/test_api_create_task_comment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_task_comment_creation_api_with_unaccepted_relation(self):
8989
data=json.dumps(dict(comment="comment")),
9090
)
9191

92-
self.assertEqual(HTTPStatus.BAD_REQUEST, actual_response.status_code)
92+
self.assertEqual(HTTPStatus.FORBIDDEN, actual_response.status_code)
9393
self.assertDictEqual(expected_response, json.loads(actual_response.data))
9494

9595
def test_task_comment_creation_api_with_task_not_existing(self):

tests/task_comments/test_api_delete_task_comment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test_task_comment_deletion_api_with_unaccepted_relation(self):
9292
content_type="application/json",
9393
)
9494

95-
self.assertEqual(HTTPStatus.BAD_REQUEST, actual_response.status_code)
95+
self.assertEqual(HTTPStatus.FORBIDDEN, actual_response.status_code)
9696
self.assertDictEqual(expected_response, json.loads(actual_response.data))
9797

9898
def test_task_comment_deletion_api_with_task_not_existing(self):

tests/task_comments/test_api_get_task_comments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_task_comment_listing_api_with_unaccepted_relation(self):
7676
content_type="application/json",
7777
)
7878

79-
self.assertEqual(HTTPStatus.BAD_REQUEST, actual_response.status_code)
79+
self.assertEqual(HTTPStatus.FORBIDDEN, actual_response.status_code)
8080
self.assertDictEqual(expected_response, json.loads(actual_response.data))
8181

8282
def test_task_comment_listing_api(self):

tests/task_comments/test_api_modify_task_comment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_task_comment_modification_api_with_unaccepted_relation(self):
119119
data=json.dumps(dict(comment="comment")),
120120
)
121121

122-
self.assertEqual(HTTPStatus.BAD_REQUEST, actual_response.status_code)
122+
self.assertEqual(HTTPStatus.FORBIDDEN, actual_response.status_code)
123123
self.assertDictEqual(expected_response, json.loads(actual_response.data))
124124

125125
def test_task_comment_modification_api_with_task_not_existing(self):

0 commit comments

Comments
 (0)