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

Method test_comment_moderation

comments/test_views.py:108–121  ·  view source on GitHub ↗

测试评论审核

(self)

Source from the content-addressed store, hash-verified

106 self.assertIn(response.status_code, [200, 302])
107
108 def test_comment_moderation(self):
109 """测试评论审核"""
110 # 设置需要审核
111 self.blog_settings.comment_need_review = True
112 self.blog_settings.save()
113
114 self.login_user()
115 url = reverse('comments:postcomment', kwargs={'article_id': self.article.id})
116 response = self.client.post(url, {'body': '待审核的评论'})
117 self.assertEqual(response.status_code, 302)
118
119 # 验证评论需要审核
120 comment = Comment.objects.filter(article=self.article).latest('id')
121 self.assertFalse(comment.is_enable)
122
123 def test_comment_display_on_article(self):
124 """测试评论在文章页显示"""

Callers

nothing calls this directly

Calls 3

login_userMethod · 0.95
postMethod · 0.80
saveMethod · 0.45

Tested by

no test coverage detected