本文整理汇总了Python中tests.factories.UserFactory.is_disabled方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.is_disabled方法的具体用法?Python UserFactory.is_disabled怎么用?Python UserFactory.is_disabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.UserFactory
的用法示例。
在下文中一共展示了UserFactory.is_disabled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_login_disabled_user
# 需要导入模块: from tests.factories import UserFactory [as 别名]
# 或者: from tests.factories.UserFactory import is_disabled [as 别名]
def test_login_disabled_user(self):
"""Logging in to a disabled account fails"""
user = UserFactory()
user.set_password('Leeloo')
user.is_disabled = True
user.save()
with assert_raises(auth.LoginDisabledError):
auth.login(user.username, 'Leeloo')
示例2: test_serialize_account_status
# 需要导入模块: from tests.factories import UserFactory [as 别名]
# 或者: from tests.factories.UserFactory import is_disabled [as 别名]
def test_serialize_account_status(self):
user = UserFactory()
info = serialize_user(user)
nt.assert_equal(info['disabled'], False)
user.is_disabled = True
info = serialize_user(user)
nt.assert_almost_equal(
int(info['disabled'].strftime('%s')),
int(datetime.utcnow().strftime('%s')),
delta=50)
nt.assert_is_instance(info['disabled'], datetime)
示例3: test_disabled_user
# 需要导入模块: from tests.factories import UserFactory [as 别名]
# 或者: from tests.factories.UserFactory import is_disabled [as 别名]
def test_disabled_user(self):
"""Test that disabled users are not in search index"""
user = UserFactory(fullname='Bettie Page')
user.save()
# Ensure user is in search index
assert_equal(len(query_user(user.fullname)['results']), 1)
# Disable the user
user.is_disabled = True
user.save()
# Ensure user is not in search index
assert_equal(len(query_user(user.fullname)['results']), 0)