def test_profile_changing_password_with_invalid_data_does_not_update_password(): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'password'}, authenticated_user=user) controller = ProfileController(request) controller.forms['password'] = invalid_form() controller.profile() assert user.password is None
def test_profile_changing_email_with_valid_data_updates_email(): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'email'}, authenticated_user=user) controller = ProfileController(request) controller.forms['email'] = form_validating_to({'email': '*****@*****.**'}) controller.profile() assert user.email == '*****@*****.**'
def test_profile_changing_password_with_valid_data_updates_password(): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'password'}, authenticated_user=user) controller = ProfileController(request) controller.forms['password'] = form_validating_to({'new_password': '******'}) controller.profile() assert user.password == 'secrets!'
def test_profile_changing_password_with_invalid_data_does_not_update_password(): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'password'}, authenticated_user=user) controller = ProfileController(request) controller.forms['password'] = invalid_form() controller.profile() assert user.password is None
def test_profile_changing_password_with_valid_data_updates_password(): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'password'}, authenticated_user=user) controller = ProfileController(request) controller.forms['password'] = form_validating_to({'new_password': '******'}) controller.profile() assert user.password == 'secrets!'
def test_profile_changing_email_with_valid_data_updates_email(): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'email'}, authenticated_user=user) controller = ProfileController(request) controller.forms['email'] = form_validating_to({'email': '*****@*****.**'}) controller.profile() assert user.email == '*****@*****.**'
def test_profile_changing_password_with_invalid_data_returns_form(): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'password'}, authenticated_user=user) controller = ProfileController(request) controller.forms['password'] = invalid_form() result = controller.profile() assert 'password_form' in result
def test_profile_changing_password_with_valid_data_redirects(): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'password'}, authenticated_user=user) controller = ProfileController(request) controller.forms['password'] = form_validating_to({'new_password': '******'}) result = controller.profile() assert isinstance(result, httpexceptions.HTTPFound)
def test_profile_changing_password_with_invalid_data_returns_form(): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'password'}, authenticated_user=user) controller = ProfileController(request) controller.forms['password'] = invalid_form() result = controller.profile() assert 'password_form' in result
def test_profile_changing_password_with_valid_data_redirects(): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'password'}, authenticated_user=user) controller = ProfileController(request) controller.forms['password'] = form_validating_to({'new_password': '******'}) result = controller.profile() assert isinstance(result, httpexceptions.HTTPFound)