测试回复评论
(self)
| 86 | self.assertEqual(response.status_code, 404) |
| 87 | |
| 88 | def test_post_reply_comment(self): |
| 89 | """测试回复评论""" |
| 90 | self.login_user() |
| 91 | # 先创建一条评论 |
| 92 | parent_comment = Comment.objects.create( |
| 93 | body='父评论', |
| 94 | author=self.user, |
| 95 | article=self.article |
| 96 | ) |
| 97 | parent_comment.is_enable = True |
| 98 | parent_comment.save() |
| 99 | |
| 100 | # 回复这条评论 |
| 101 | url = reverse('comments:postcomment', kwargs={'article_id': self.article.id}) |
| 102 | response = self.client.post(url, { |
| 103 | 'body': '这是回复', |
| 104 | 'parent_comment_id': parent_comment.id |
| 105 | }) |
| 106 | self.assertIn(response.status_code, [200, 302]) |
| 107 | |
| 108 | def test_comment_moderation(self): |
| 109 | """测试评论审核""" |
nothing calls this directly
no test coverage detected