本文整理汇总了Python中horus.tests.models.User.get_by_pk方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_pk方法的具体用法?Python User.get_by_pk怎么用?Python User.get_by_pk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horus.tests.models.User
的用法示例。
在下文中一共展示了User.get_by_pk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_profile_update_password
# 需要导入模块: from horus.tests.models import User [as 别名]
# 或者: from horus.tests.models.User import get_by_pk [as 别名]
def test_profile_update_password(self):
from horus.views import ProfileController
from horus.interfaces import IHorusSession
from horus.events import ProfileUpdatedEvent
from horus.models import crypt
from horus.interfaces import IHorusUserClass
from horus.tests.models import User
from horus.interfaces import IHorusActivationClass
from horus.tests.models import Activation
self.config.registry.registerUtility(Activation, IHorusActivationClass)
self.config.registry.registerUtility(User, IHorusUserClass)
self.config.add_route('index', '/')
self.config.include('horus')
user = User(user_name='sontek', email='[email protected]')
user.set_password('temp')
self.session.add(user)
self.session.flush()
def handle_profile_updated(event):
request = event.request
session = request.registry.getUtility(IHorusSession)
session.commit()
self.config.add_subscriber(handle_profile_updated, ProfileUpdatedEvent)
request = self.get_csrf_request(post={
'Email': '[email protected]',
'Password': {
'Password': 'test123',
'Password-confirm': 'test123',
},
}, request_method='POST')
request.context = user
request.matchdict = Mock()
get = Mock()
get.return_value = user.pk
request.matchdict.get = get
flash = Mock()
request.session.flash = flash
view = ProfileController(request)
view.edit_profile()
new_user = User.get_by_pk(request, user.pk)
assert new_user.email == '[email protected]'
assert not crypt.check(user.password, 'temp' + user.salt)