当前位置: 首页>>代码示例>>Python>>正文


Python Post.delete方法代码示例

本文整理汇总了Python中forums.models.Post.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Post.delete方法的具体用法?Python Post.delete怎么用?Python Post.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forums.models.Post的用法示例。


在下文中一共展示了Post.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_delete_last_and_only_post_in_thread

# 需要导入模块: from forums.models import Post [as 别名]
# 或者: from forums.models.Post import delete [as 别名]
 def test_delete_last_and_only_post_in_thread(self):
     """Deleting the only post in a thread should delete the thread"""
     forum = Forum.objects.get(pk=1)
     thread = Thread(title="test", forum=forum, creator_id=118533)
     thread.save()
     post = Post(thread=thread, content="test", author=thread.creator)
     post.save()
     eq_(1, thread.post_set.count())
     post.delete()
     eq_(0, Thread.uncached.filter(pk=thread.id).count())
开发者ID:AutomatedTester,项目名称:kitsune,代码行数:12,代码来源:test_models.py

示例2: test_last_post_updated

# 需要导入模块: from forums.models import Post [as 别名]
# 或者: from forums.models.Post import delete [as 别名]
    def test_last_post_updated(self):
        """Adding/Deleting the last post in a thread and forum should
        update the last_post field
        """
        thread = Thread.objects.get(pk=4)
        user = User.objects.get(pk=118533)

        # add a new post, then check that last_post is updated
        new_post = Post(thread=thread, content="test", author=user)
        new_post.save()
        forum = Forum.objects.get(pk=1)
        thread = Thread.objects.get(pk=thread.id)
        eq_(forum.last_post.id, new_post.id)
        eq_(thread.last_post.id, new_post.id)

        # delete the new post, then check that last_post is updated
        new_post.delete()
        forum = Forum.objects.get(pk=1)
        thread = Thread.objects.get(pk=thread.id)
        eq_(forum.last_post.id, 25)
        eq_(thread.last_post.id, 25)
开发者ID:AutomatedTester,项目名称:kitsune,代码行数:23,代码来源:test_models.py


注:本文中的forums.models.Post.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。