def test_forgot_password_invalid_password(self): from pyramid_signup.views import ForgotPasswordController from pyramid_mailer.interfaces import IMailer from pyramid_mailer.mailer import DummyMailer self.config.add_route('index', '/') self.config.include('pyramid_signup') self.config.registry.registerUtility(DummyMailer(), IMailer) from pyramid_signup.models import User user = User(username='******', password='******', email='*****@*****.**') 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
def test_forgot_password_valid_user(self): from pyramid_signup.views import ForgotPasswordController from pyramid_mailer.interfaces import IMailer from pyramid_mailer.mailer import DummyMailer self.config.add_route('index', '/') self.config.include('pyramid_signup') self.config.registry.registerUtility(DummyMailer(), IMailer) from pyramid_signup.models import User user = User(username='******', password='******', email='*****@*****.**') self.session.add(user) self.session.flush() request = self.get_csrf_request(post={ 'Email': '*****@*****.**' }, request_method='POST') request.user = None flash = Mock() request.session.flash = flash view = ForgotPasswordController(request) response = view.forgot_password() flash.assert_called_with(u'Please check your e-mail to reset your password.', 'success') assert response.status_int == 302
def test_forgot_password_logged_in_redirects(self): from pyramid_signup.views import ForgotPasswordController self.config.add_route('index', '/') self.config.include('pyramid_signup') request = testing.DummyRequest() request.user = Mock() view = ForgotPasswordController(request) response = view.forgot_password() assert response.status_int == 302
def test_forgot_password_loads(self): from pyramid_signup.views import ForgotPasswordController self.config.add_route('index', '/') self.config.include('pyramid_signup') request = testing.DummyRequest() request.user = None view = ForgotPasswordController(request) response = view.forgot_password() assert response.get('form', None)