def test_put_with_file_attachment_comment(self): """Testing the PUT review-requests/<id>/reviews/<id>/replies/<id>/file-attachment-comments/ API """ new_comment_text = 'My new comment text' review_request = self.create_review_request(submitter=self.user, publish=True) file_attachment = self.create_file_attachment(review_request) review = self.create_review(review_request) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=self.user) reply_comment = self.create_file_attachment_comment( reply, file_attachment, reply_to=comment) rsp = self.apiPut( get_review_reply_file_attachment_comment_item_url( reply, reply_comment.pk), {'text': new_comment_text}, expected_mimetype=( review_reply_file_attachment_comment_item_mimetype)) self.assertEqual(rsp['stat'], 'ok') reply_comment = FileAttachmentComment.objects.get( pk=rsp['file_attachment_comment']['id']) self.assertEqual(reply_comment.text, new_comment_text)
def setup_basic_delete_test(self, user, with_local_site, local_site_name): review_request = self.create_review_request( with_local_site=with_local_site, submitter=user, publish=True) file_attachment = self.create_file_attachment(review_request) review = self.create_review(review_request, user=user, publish=True) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=user) reply_comment = self.create_file_attachment_comment(reply, file_attachment, reply_to=comment) return (get_review_reply_file_attachment_comment_item_url( reply, reply_comment.pk, local_site_name), [reply_comment, reply])
def setup_review_request_child_test(self, review_request): file_attachment = self.create_file_attachment(review_request) review = self.create_review(review_request, user=self.user, publish=True) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=self.user) reply_comment = self.create_file_attachment_comment( reply, file_attachment, reply_to=comment) return ( get_review_reply_file_attachment_comment_item_url( reply, reply_comment.pk), review_reply_file_attachment_comment_item_mimetype)
def setup_basic_put_test(self, user, with_local_site, local_site_name, put_valid_data): review_request = self.create_review_request( with_local_site=with_local_site, submitter=user, publish=True) file_attachment = self.create_file_attachment(review_request) review = self.create_review(review_request, user=user, publish=True) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=user) reply_comment = self.create_file_attachment_comment(reply, file_attachment, reply_to=comment) return (get_review_reply_file_attachment_comment_item_url( reply, reply_comment.pk, local_site_name), review_reply_file_attachment_comment_item_mimetype, { 'text': 'Test comment', }, reply_comment, [])
def setup_basic_delete_test(self, user, with_local_site, local_site_name): review_request = self.create_review_request( with_local_site=with_local_site, submitter=user, publish=True) file_attachment = self.create_file_attachment(review_request) review = self.create_review(review_request, user=user, publish=True) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=user) reply_comment = self.create_file_attachment_comment( reply, file_attachment, reply_to=comment) return ( get_review_reply_file_attachment_comment_item_url( reply, reply_comment.pk, local_site_name), [reply_comment, reply] )
def test_delete_no_access(self): """Testing the DELETE review-requests/<id>/reviews/<id>/replies/<id>/file-attachment-comments/<id>/ API and Permission Denied """ review_request = self.create_review_request(submitter=self.user, publish=True) file_attachment = self.create_file_attachment(review_request) review = self.create_review(review_request) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=self.user) reply_comment = self.create_file_attachment_comment( reply, file_attachment, reply_to=comment) self.client.login(username="******", password="******") self.apiDelete( get_review_reply_file_attachment_comment_item_url( reply, reply_comment.pk), expected_status=403)
def test_delete(self): """Testing the DELETE review-requests/<id>/reviews/<id>/replies/<id>/file-attachment-comments/<id>/ API """ review_request = self.create_review_request(submitter=self.user, publish=True) file_attachment = self.create_file_attachment(review_request) review = self.create_review(review_request) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=self.user) reply_comment = self.create_file_attachment_comment( reply, file_attachment, reply_to=comment) self.apiDelete(get_review_reply_file_attachment_comment_item_url( reply, reply_comment.pk)) comments = FileAttachmentComment.objects.filter(review=reply, reply_to=comment) self.assertEqual(comments.count(), 0)
def test_delete_with_local_site_no_access(self): """Testing the DELETE review-requests/<id>/reviews/<id>/replies/<id>/file-attachment-comments/<id>/ API with a local site and Permission Denied """ review_request = self.create_review_request(submitter=self.user, with_local_site=True, publish=True) file_attachment = self.create_file_attachment(review_request) review = self.create_review(review_request) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=self.user) reply_comment = self.create_file_attachment_comment( reply, file_attachment, reply_to=comment) self._login_user(local_site=True) self.apiDelete( get_review_reply_file_attachment_comment_item_url( reply, reply_comment.pk, self.local_site_name), expected_status=403)
def setup_basic_put_test(self, user, with_local_site, local_site_name, put_valid_data): review_request = self.create_review_request( with_local_site=with_local_site, submitter=user, publish=True) file_attachment = self.create_file_attachment(review_request) review = self.create_review(review_request, user=user, publish=True) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=user) reply_comment = self.create_file_attachment_comment( reply, file_attachment, reply_to=comment) return ( get_review_reply_file_attachment_comment_item_url( reply, reply_comment.pk, local_site_name), review_reply_file_attachment_comment_item_mimetype, { 'text': 'Test comment', }, reply_comment, [])