diff --git a/backend/tests/proposal/test_comment_api.py b/backend/tests/proposal/test_comment_api.py index 20f940df..d115577e 100644 --- a/backend/tests/proposal/test_comment_api.py +++ b/backend/tests/proposal/test_comment_api.py @@ -21,7 +21,16 @@ class TestAPI(BaseUserConfig): content_type='application/json' ) self.assertStatus(comment_res, 201) - + + def test_invalid_proposal_id_create_comment(self): + comment_res = self.app.post( + "/api/v1/proposals/12345/comments", + data=json.dumps(test_comment), + headers=self.headers, + content_type='application/json' + ) + self.assertStatus(comment_res, 404) + def test_invalid_signature_create_comment(self): proposal = Proposal( status="LIVE" @@ -68,3 +77,29 @@ class TestAPI(BaseUserConfig): reply_res.json["parentCommentId"], comment_res.json["id"] ) + + def test_invalid_parent_comment_id_create_reply(self): + proposal = Proposal( + status="LIVE" + ) + db.session.add(proposal) + db.session.commit() + proposal_id = proposal.id + + comment_res = self.app.post( + "/api/v1/proposals/{}/comments".format(proposal_id), + data=json.dumps(test_comment), + headers=self.headers, + content_type='application/json' + ) + self.assertStatus(comment_res, 201) + + test_reply_copy = test_reply.copy() + test_reply_copy["parentCommentId"] = comment_res.json["id"] + 1 + reply_res = self.app.post( + "/api/v1/proposals/{}/comments".format(proposal_id), + data=json.dumps(test_reply_copy), + headers=self.headers, + content_type='application/json' + ) + self.assertStatus(reply_res, 400)