本文整理汇总了Python中auth.models.User.key方法的典型用法代码示例。如果您正苦于以下问题:Python User.key方法的具体用法?Python User.key怎么用?Python User.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth.models.User
的用法示例。
在下文中一共展示了User.key方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AutocompleteViewsTestCase
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import key [as 别名]
class AutocompleteViewsTestCase(DjangoTestCase):
def setUp(self):
# assert self.client.login(email="[email protected]")
self.activeUser = User(
email='[email protected]',
first_name='Active',
last_name='User',
is_active=True,
password='123456'
)
_reindex(self.activeUser)
self.activeUser.save()
self.inactiveUser = User(
email='[email protected]',
first_name='Inactive',
last_name='User',
is_active=False,
password='123456'
)
_reindex(self.inactiveUser)
self.inactiveUser.save()
def test_active_user(self):
response = self.client.get("/auth/search.txt", {'q': 'Active'})
self.assertEqual(response.content,
"%s|%s\n" % (self.activeUser, self.activeUser.key()))
def test_inactive_user(self):
response = self.client.get("/auth/search.txt", {'q': 'Inactive'})
self.assertEqual(response.content, "")
示例2: test_sync_existing_with_dj_role
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import key [as 别名]
def test_sync_existing_with_dj_role(self):
us = User(email=self.user['email'],
external_id=self.user['member_id'],
roles=[roles.DJ, roles.REVIEWER])
us.put()
self.sync()
us = User.all().filter('__key__ =', us.key()).fetch(1)[0]
eq_(set(us.roles), set((roles.DJ, roles.REVIEWER)))
示例3: test_deactivate
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import key [as 别名]
def test_deactivate(self):
us = User(email='[email protected]', external_id=23)
us.put()
resp = self.client.post(self.url, {'external_id': 23})
eq_(resp.status_code, 200)
us = User.all().filter('__key__ =', us.key()).fetch(1)[0]
eq_(us.is_active, False)
示例4: test_preserve_superuser
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import key [as 别名]
def test_preserve_superuser(self):
us = User(email=self.user['email'],
external_id=self.user['member_id'],
is_superuser=True)
us.put()
self.sync()
us = User.all().filter('__key__ =', us.key()).fetch(1)[0]
eq_(us.is_superuser, True)
示例5: test_sync_existing_without_id
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import key [as 别名]
def test_sync_existing_without_id(self):
us = User(email=self.user['email'])
us.put()
self.sync()
us = User.all().filter('__key__ =', us.key()).fetch(1)[0]
eq_(us.first_name, self.user['name_first'])
eq_(us.last_name, self.user['name_last'])
eq_(us.email, self.user['email'])
eq_(us.dj_name, self.user['nick'])
eq_(us.external_id, self.user['member_id'])
eq_(us.is_superuser, False)
eq_(us.is_active, True)
eq_(us.roles, [roles.DJ])
eq_(User.all().filter('email =', self.user['email']).count(2), 1)