本文整理汇总了Python中app.user.models.User.is_not_deleted方法的典型用法代码示例。如果您正苦于以下问题:Python User.is_not_deleted方法的具体用法?Python User.is_not_deleted怎么用?Python User.is_not_deleted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.user.models.User
的用法示例。
在下文中一共展示了User.is_not_deleted方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import is_not_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