From c154317b266ffb258f6a7b2ab5ea95de45c5de81 Mon Sep 17 00:00:00 2001 From: Burhanuddin Kamlapurwala <41769631+b-thebest@users.noreply.github.com> Date: Fri, 23 Jul 2021 03:32:07 +0530 Subject: [PATCH] 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//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//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> --- app/api/dao/task_comment.py | 2 +- app/api/resources/task_comment.py | 2 +- tests/task_comments/test_api_create_task_comment.py | 2 +- tests/task_comments/test_api_delete_task_comment.py | 2 +- tests/task_comments/test_api_get_task_comments.py | 2 +- tests/task_comments/test_api_modify_task_comment.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/api/dao/task_comment.py b/app/api/dao/task_comment.py index c01e81a15..577190ed2 100644 --- a/app/api/dao/task_comment.py +++ b/app/api/dao/task_comment.py @@ -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: diff --git a/app/api/resources/task_comment.py b/app/api/resources/task_comment.py index 99ec21288..12a75e8ee 100644 --- a/app/api/resources/task_comment.py +++ b/app/api/resources/task_comment.py @@ -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}
" f"{messages.TOKEN_IS_INVALID}
" f"{messages.AUTHORISATION_TOKEN_IS_MISSING}
" diff --git a/tests/task_comments/test_api_create_task_comment.py b/tests/task_comments/test_api_create_task_comment.py index 23388d7e9..b5d847f2f 100644 --- a/tests/task_comments/test_api_create_task_comment.py +++ b/tests/task_comments/test_api_create_task_comment.py @@ -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): diff --git a/tests/task_comments/test_api_delete_task_comment.py b/tests/task_comments/test_api_delete_task_comment.py index a36cb640e..8b359f126 100644 --- a/tests/task_comments/test_api_delete_task_comment.py +++ b/tests/task_comments/test_api_delete_task_comment.py @@ -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): diff --git a/tests/task_comments/test_api_get_task_comments.py b/tests/task_comments/test_api_get_task_comments.py index 08fe3bf5e..21a687ffd 100644 --- a/tests/task_comments/test_api_get_task_comments.py +++ b/tests/task_comments/test_api_get_task_comments.py @@ -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): diff --git a/tests/task_comments/test_api_modify_task_comment.py b/tests/task_comments/test_api_modify_task_comment.py index 7376deb98..d2d4deb0f 100644 --- a/tests/task_comments/test_api_modify_task_comment.py +++ b/tests/task_comments/test_api_modify_task_comment.py @@ -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):