def test_reset_password_returns_form_when_validation_fails(): request = DummyRequest(method='POST') controller = ResetPasswordController(request) controller.form = invalid_form() result = controller.reset_password() assert result == {'form': 'invalid form'}
def test_reset_password_redirects_on_success(): request = DummyRequest(method='POST') user = FakeUser(password='******') controller = ResetPasswordController(request) controller.form = form_validating_to({'user': user, 'password': '******'}) result = controller.reset_password() assert isinstance(result, httpexceptions.HTTPRedirection)
def test_reset_password_sets_user_password_from_form(): request = DummyRequest(method='POST') elephant = FakeUser(password='******') controller = ResetPasswordController(request) controller.form = form_validating_to({'user': elephant, 'password': '******'}) controller.reset_password() assert elephant.password == 's3cure!'
def test_reset_password_emits_event(event, notify): request = DummyRequest(method='POST') user = FakeUser(password='******') controller = ResetPasswordController(request) controller.form = form_validating_to({'user': user, 'password': '******'}) controller.reset_password() event.assert_called_with(request, user) notify.assert_called_with(event.return_value)
def test_reset_password_deletes_activation(): request = DummyRequest(method='POST') user = FakeUser(password='******') user.activation = mock.sentinel.activation controller = ResetPasswordController(request) controller.form = form_validating_to({'user': user, 'password': '******'}) controller.reset_password() assert mock.sentinel.activation in request.db.deleted