MCPcopy
hub / github.com/liangliangyy/DjangoBlog / test_post_reply_comment

Method test_post_reply_comment

comments/test_views.py:88–106  ·  view source on GitHub ↗

测试回复评论

(self)

Source from the content-addressed store, hash-verified

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 """测试评论审核"""

Callers

nothing calls this directly

Calls 4

login_userMethod · 0.95
createMethod · 0.80
postMethod · 0.80
saveMethod · 0.45

Tested by

no test coverage detected