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


Python User.is_deleted方法代码示例

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


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

示例1: test

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import is_deleted [as 别名]

#.........这里部分代码省略.........
        db.session.add(t3u2)
        db.session.add(t4u1)
        db.session.commit()

        assert len(u1.thanks_received.all()) == 4
        assert len(u2.thanks_received.all()) == 3
        assert len(u3.thanks_received.all()) == 2
        assert len(u4.thanks_received.all()) == 1

        # delete thank

        t1.make_deleted()
        db.session.add(t1)
        db.session.commit()

        assert len(u1.thanks_received.all()) == 3
        assert len(u2.thanks_received.all()) == 2
        assert len(u3.thanks_received.all()) == 1
        assert len(u4.thanks_received.all()) == 0

        # delete thank to user

        t2u1.make_deleted()
        db.session.add(t2u1)
        db.session.commit()

        assert len(u1.thanks_received.all()) == 2
        assert len(u2.thanks_received.all()) == 2
        assert len(u3.thanks_received.all()) == 1
        assert len(u4.thanks_received.all()) == 0

        # follow users

        u1u1 = Follow(u1.id, u1.id)
        u1u2 = Follow(u1.id, u2.id)
        u1u3 = Follow(u1.id, u3.id)
        u1u4 = Follow(u1.id, u4.id)

        u2u1 = Follow(u2.id, u1.id)
        u2u2 = Follow(u2.id, u2.id)
        u2u3 = Follow(u2.id, u3.id)

        u3u1 = Follow(u3.id, u1.id)
        u3u2 = Follow(u3.id, u2.id)

        u4u1 = Follow(u4.id, u1.id)

        db.session.add(u1u1)
        db.session.add(u1u2)
        db.session.add(u1u3)
        db.session.add(u1u4)
        db.session.add(u2u1)
        db.session.add(u2u2)
        db.session.add(u2u3)
        db.session.add(u3u1)
        db.session.add(u3u2)
        db.session.add(u4u1)
        db.session.commit()

        assert len(u1.following.all()) == 4
        assert len(u2.following.all()) == 3
        assert len(u3.following.all()) == 2
        assert len(u4.following.all()) == 1

        # unfollow users

        u1u1.make_deleted()
        u2u2.make_deleted()

        db.session.add(u1u1)
        db.session.add(u2u2)
        db.session.commit()

        assert len(u1.following.all()) == 3
        assert len(u2.following.all()) == 2
        assert len(u3.following.all()) == 2
        assert len(u4.following.all()) == 1

        # change user statuses

        u2.make_deactivated()
        u3.make_deleted()

        db.session.add(u3)
        db.session.add(u4)
        db.session.commit()

        assert u2.is_deactivated() == True
        assert u2.is_activated() == False
        assert u2.is_active() == True
        assert u3.is_deleted() == True
        assert u3.is_not_deleted() == False

        assert u2 in u1.following.all()
        assert u3 not in u1.following.all()

        assert len(u1.following.all()) == 2
        assert len(u2.following.all()) == 1
        assert len(u3.following.all()) == 2
        assert len(u4.following.all()) == 1
开发者ID:dogukantufekci,项目名称:thankspress,代码行数:104,代码来源:test.py


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