本文整理汇总了Python中horus.views.ForgotPasswordController.forgot_password方法的典型用法代码示例。如果您正苦于以下问题:Python ForgotPasswordController.forgot_password方法的具体用法?Python ForgotPasswordController.forgot_password怎么用?Python ForgotPasswordController.forgot_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horus.views.ForgotPasswordController
的用法示例。
在下文中一共展示了ForgotPasswordController.forgot_password方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_forgot_password_invalid_password
# 需要导入模块: from horus.views import ForgotPasswordController [as 别名]
# 或者: from horus.views.ForgotPasswordController import forgot_password [as 别名]
def test_forgot_password_invalid_password(self):
from horus.views import ForgotPasswordController
from pyramid_mailer.interfaces import IMailer
from pyramid_mailer.mailer import DummyMailer
from horus.interfaces import IUserClass
from horus.tests.models import User
self.config.registry.registerUtility(User, IUserClass)
self.config.add_route('index', '/')
self.config.include('horus')
self.config.registry.registerUtility(DummyMailer(), IMailer)
user = User(username='sontek', password='temp',
email='[email protected]')
user.password = 'foo'
self.session.add(user)
self.session.flush()
request = self.get_csrf_request(post={
'email': 'sontek'
}, request_method='POST')
request.user = None
view = ForgotPasswordController(request)
response = view.forgot_password()
assert len(response['errors']) == 1
示例2: test_forgot_password_valid_user
# 需要导入模块: from horus.views import ForgotPasswordController [as 别名]
# 或者: from horus.views.ForgotPasswordController import forgot_password [as 别名]
def test_forgot_password_valid_user(self):
from horus.views import ForgotPasswordController
from pyramid_mailer.interfaces import IMailer
from pyramid_mailer.mailer import DummyMailer
from horus.interfaces import IUserClass
from horus.tests.models import User
self.config.registry.registerUtility(User, IUserClass)
self.config.add_route('index', '/')
self.config.include('horus')
self.config.registry.registerUtility(DummyMailer(), IMailer)
user = User(username='sontek', password='temp',
email='[email protected]')
user.password = 'foo'
self.session.add(user)
self.session.flush()
request = self.get_csrf_request(post={
'email': '[email protected]'
}, request_method='POST')
request.user = None
view = ForgotPasswordController(request)
with patch('horus.views.FlashMessage') as FlashMessage:
response = view.forgot_password()
FlashMessage.assert_called_with(request,
view.Str.reset_password_email_sent, kind="success")
assert response.status_int == 302
示例3: test_forgot_password_valid_user
# 需要导入模块: from horus.views import ForgotPasswordController [as 别名]
# 或者: from horus.views.ForgotPasswordController import forgot_password [as 别名]
def test_forgot_password_valid_user(self):
from horus.views import ForgotPasswordController
from pyramid_mailer.interfaces import IMailer
from pyramid_mailer.mailer import DummyMailer
from horus.interfaces import IUserClass
from horus.tests.models import User
self.config.registry.registerUtility(User, IUserClass)
self.config.add_route('index', '/')
self.config.include('horus')
self.config.registry.registerUtility(DummyMailer(), IMailer)
user = User(username='sontek', password='temp', email='[email protected]')
user.password = 'foo'
self.session.add(user)
self.session.flush()
request = self.get_csrf_request(post={
'email': '[email protected]'
}, request_method='POST')
request.user = None
flash = Mock()
request.session.flash = flash
view = ForgotPasswordController(request)
response = view.forgot_password()
flash.assert_called_with(
'Please check your e-mail to reset your password.', 'success')
assert response.status_int == 302
示例4: test_forgot_password_logged_in_redirects
# 需要导入模块: from horus.views import ForgotPasswordController [as 别名]
# 或者: from horus.views.ForgotPasswordController import forgot_password [as 别名]
def test_forgot_password_logged_in_redirects(self):
from horus.views import ForgotPasswordController
from horus.interfaces import IUserClass
from horus.tests.models import User
self.config.registry.registerUtility(User, IUserClass)
self.config.add_route('index', '/')
self.config.include('horus')
request = testing.DummyRequest()
request.user = Mock()
view = ForgotPasswordController(request)
response = view.forgot_password()
assert response.status_int == 302
示例5: test_forgot_password_loads
# 需要导入模块: from horus.views import ForgotPasswordController [as 别名]
# 或者: from horus.views.ForgotPasswordController import forgot_password [as 别名]
def test_forgot_password_loads(self):
from horus.views import ForgotPasswordController
from horus.interfaces import IUserClass
from horus.tests.models import User
from horus.interfaces import IActivationClass
from horus.tests.models import Activation
self.config.registry.registerUtility(Activation, IActivationClass)
self.config.registry.registerUtility(User, IUserClass)
self.config.add_route('index', '/')
self.config.include('horus')
request = testing.DummyRequest()
request.user = None
view = ForgotPasswordController(request)
response = view.forgot_password()
assert response.get('form', None)
示例6: forgot
# 需要导入模块: from horus.views import ForgotPasswordController [as 别名]
# 或者: from horus.views.ForgotPasswordController import forgot_password [as 别名]
def forgot(self):
request = self.request
controller = ForgotPasswordController(request)
form = self.forgot_form
result = controller.forgot_password()
if isinstance(result, dict):
if 'errors' in result:
error = colander.Invalid(
form.schema,
messages.INVALID_FORM
)
error.children = result.pop('errors')
form.widget.handle_error(form, error)
result = {
'form': {
'forgot': form.render()
}
}
else:
# TODO: take care of flash success message
return None
return result