def test_post_with_http_303(self): """Testing the POST review-requests/<id>/reviews/<id>/replies/<id>/file-attachment-comments/ API with second instance of same reply """ 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) self.create_file_attachment_comment(reply, file_attachment, reply_to=comment) # Now post another reply to the same comment in the same review. rsp = self.apiPost( get_review_reply_file_attachment_comment_list_url(reply), { 'reply_to_id': comment.pk, 'text': 'Test comment' }, expected_status=303, expected_mimetype=( review_reply_file_attachment_comment_item_mimetype)) self.assertEqual(rsp['stat'], 'ok') self.check_post_result(self.user, rsp, reply, comment, file_attachment)
def test_post_with_inactive_file_attachment(self): """Testing the POST review-requests/<id>/reviews/<id>/replies/<id>/file-attachment-comments/ API with inactive file attachment """ review_request = self.create_review_request(submitter=self.user) file_attachment = self.create_file_attachment(review_request) review_request.publish(review_request.submitter) review = self.create_review(review_request, username='******') comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=self.user) comments_url = get_review_reply_file_attachment_comment_list_url(reply) # Make the file attachment inactive. file_attachment = comment.file_attachment review_request = file_attachment.review_request.get() review_request.inactive_file_attachments.add(file_attachment) review_request.file_attachments.remove(file_attachment) # Now make the reply. rsp = self.apiPost( comments_url, { 'reply_to_id': comment.id, 'text': 'Test comment', }, expected_mimetype=( review_reply_file_attachment_comment_item_mimetype)) self.assertEqual(rsp['stat'], 'ok') self.check_post_result(self.user, rsp, reply, comment, file_attachment)
def test_post_reply_with_file_attachment_comment(self): """Testing the POST review-requests/<id>/reviews/<id>/replies/<id>/file-attachment-comments/ API""" comment_text = "My Comment Text" review_request = self.create_review_request(submitter=self.user) file_attachment = self.create_file_attachment(review_request) review_request.publish(review_request.submitter) review = self.create_review(review_request) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=self.user) comments_url = get_review_reply_file_attachment_comment_list_url(reply) rsp = self.apiPost( comments_url, { 'reply_to_id': comment.id, 'text': 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, comment_text) return rsp, comment, comments_url
def test_post_reply_with_file_attachment_comment_and_local_site(self): """Testing the POST review-requests/<id>/reviews/<id>/replies/<id>/file-attachment-comments/ API with a local site""" comment_text = "My Comment Text" 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, username='******') comment = self.create_file_attachment_comment(review, file_attachment) user = self._login_user(local_site=True) reply = self.create_reply(review, user=user) comments_url = get_review_reply_file_attachment_comment_list_url( reply, self.local_site_name) rsp = self.apiPost( comments_url, { 'reply_to_id': comment.id, 'text': 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, comment_text) return rsp, comment, comments_url
def test_post_with_file_attachment_comment_http_303(self): """Testing the POST review-requests/<id>/reviews/<id>/replies/<id>/file-attachment-comments/ API and 303 See Other """ 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) # Now post another reply to the same comment in the same review. rsp = self.apiPost( get_review_reply_file_attachment_comment_list_url(reply), { 'reply_to_id': comment.pk, 'text': comment_text }, expected_status=303, 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, comment_text)
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) self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=self.user) return (get_review_reply_file_attachment_comment_list_url(reply), review_reply_file_attachment_comment_list_mimetype)
def setup_basic_post_test(self, user, with_local_site, local_site_name, post_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) return (get_review_reply_file_attachment_comment_list_url( reply, local_site_name), review_reply_file_attachment_comment_item_mimetype, { 'reply_to_id': comment.pk, 'text': 'Test comment', }, [reply, comment, file_attachment])
def setup_basic_post_test(self, user, with_local_site, local_site_name, post_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) return ( get_review_reply_file_attachment_comment_list_url( reply, local_site_name), review_reply_file_attachment_comment_item_mimetype, { 'reply_to_id': comment.pk, 'text': 'Test comment', }, [reply, comment, file_attachment])
def setup_basic_get_test(self, user, with_local_site, local_site_name, populate_items): 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) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=user) if populate_items: items = [ self.create_file_attachment_comment(reply, file_attachment, reply_to=comment), ] else: items = [] return (get_review_reply_file_attachment_comment_list_url( reply, local_site_name), review_reply_file_attachment_comment_list_mimetype, items)
def setup_basic_get_test(self, user, with_local_site, local_site_name, populate_items): 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) comment = self.create_file_attachment_comment(review, file_attachment) reply = self.create_reply(review, user=user) if populate_items: items = [ self.create_file_attachment_comment(reply, file_attachment, reply_to=comment), ] else: items = [] return ( get_review_reply_file_attachment_comment_list_url( reply, local_site_name), review_reply_file_attachment_comment_list_mimetype, items)