本文整理汇总了Python中comments.models.Comment.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.delete方法的具体用法?Python Comment.delete怎么用?Python Comment.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comments.models.Comment
的用法示例。
在下文中一共展示了Comment.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_comment
# 需要导入模块: from comments.models import Comment [as 别名]
# 或者: from comments.models.Comment import delete [as 别名]
def test_delete_comment(self):
sound = Sound.objects.get(id=19)
user = User.objects.get(id=2)
current_num_comments = sound.num_comments
comment = Comment(content_object=sound,
user=user,
comment="Test comment")
sound.add_comment(comment)
comment.delete()
sound = Sound.objects.get(id=19)
self.assertEqual(current_num_comments, sound.num_comments)
self.assertEqual(sound.is_index_dirty, True)
示例2: CommentTests
# 需要导入模块: from comments.models import Comment [as 别名]
# 或者: from comments.models.Comment import delete [as 别名]
class CommentTests(_BaseIdeaTest):
def setUp(self):
super(CommentTests, self).setUp()
self.comment = Comment(content="This is commenty comment",
owner=self.user,
idea=self.idea)
self.comment.save()
def tearDown(self):
super(CommentTests, self).tearDown()
self.comment.delete()
def test_comment_view_contains_expected_information(self):
url = reverse('comment-detail', kwargs={'pk':self.comment.pk})
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertContains(response, 'content')
self.assertContains(response, 'owner')
self.assertContains(response, 'idea')