More invalid comment tests.

This commit is contained in:
Will O'Beirne 2018-11-27 15:29:41 -05:00
parent 8c6d5265bf
commit e24ed31367
No known key found for this signature in database
GPG Key ID: 44C190DB5DEAF9F6
1 changed files with 36 additions and 1 deletions

View File

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