def test_post_email_form_with_invalid_data_does_not_change_email( self, invalid_form, pyramid_request): controller = views.AccountController(pyramid_request) controller.forms['email'] = invalid_form() original_email = pyramid_request.authenticated_user.email controller.post_email_form() assert pyramid_request.authenticated_user.email == original_email
def test_post_email_form_with_valid_data_changes_email( self, form_validating_to, pyramid_request): controller = views.AccountController(pyramid_request) controller.forms['email'] = form_validating_to( {'email': 'new_email_address'}) controller.post_email_form() assert pyramid_request.authenticated_user.email == 'new_email_address'
def test_post_password_form_with_invalid_data_does_not_change_password( self, invalid_form, pyramid_request): user = pyramid_request.authenticated_user user.password = '******' controller = views.AccountController(pyramid_request) controller.forms['password'] = invalid_form() controller.post_password_form() assert user.check_password('original password')
def test_post_password_form_with_valid_data_changes_password( self, form_validating_to, pyramid_request): controller = views.AccountController(pyramid_request) controller.forms['password'] = form_validating_to( {'new_password': '******'}) controller.post_password_form() assert pyramid_request.authenticated_user.check_password( 'my_new_password')
def test_post_password_form_with_invalid_data_returns_template_data( self, invalid_form, pyramid_request): controller = views.AccountController(pyramid_request) controller.forms['password'] = invalid_form() result = controller.post_password_form() assert result == { 'email': pyramid_request.authenticated_user.email, 'email_form': controller.forms['email'].render(), 'password_form': controller.forms['password'].render(), }