def test_post_returns_form_when_validation_fails(self, invalid_form, pyramid_request): controller = views.ResetController(pyramid_request) controller.form = invalid_form() result = controller.post() assert result == {'form': 'invalid form'}
def test_post_redirects_on_success(self, factories, form_validating_to, pyramid_request): user = factories.User(password='******') controller = views.ResetController(pyramid_request) controller.form = form_validating_to({ 'user': user, 'password': '******' }) result = controller.post() assert isinstance(result, httpexceptions.HTTPRedirection)
def test_post_emits_event(self, event, factories, form_validating_to, notify, pyramid_request): user = factories.User(password='******') controller = views.ResetController(pyramid_request) controller.form = form_validating_to({ 'user': user, 'password': '******' }) controller.post() event.assert_called_with(pyramid_request, user) notify.assert_called_with(event.return_value)
def test_post_sets_user_password_from_form(self, factories, form_validating_to, pyramid_request): elephant = factories.User(password='******') controller = views.ResetController(pyramid_request) controller.form = form_validating_to({ 'user': elephant, 'password': '******' }) controller.post() assert elephant.check_password('s3cure!')