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):