def test_post_400s_with_bogus_formid(self): user = FakeUser() request = DummyRequest(post={'__formid__': 'hax0rs'}, authenticated_user=user) with pytest.raises(httpexceptions.HTTPBadRequest): views.ProfileController(request).post()
def test_post_changing_password_with_invalid_data_does_not_update_password(self, req, user): req.POST = {'__formid__': 'password'} controller = views.ProfileController(req) controller.forms['password'] = invalid_form() controller.post() assert user.password is None
def test_post_changing_password_with_invalid_data_returns_form(self, req): req.POST = {'__formid__': 'password'} controller = views.ProfileController(req) controller.forms['password'] = invalid_form() result = controller.post() assert 'password_form' in result
def test_post_changing_email_with_invalid_data_does_not_update_email(self, req, user): req.POST = {'__formid__': 'email'} controller = views.ProfileController(req) controller.forms['email'] = invalid_form() controller.post() assert user.email is None
def test_post_changing_password_with_valid_data_redirects(self, req): req.POST = {'__formid__': 'password'} controller = views.ProfileController(req) controller.forms['password'] = form_validating_to( {'new_password': '******'}) result = controller.post() assert isinstance(result, httpexceptions.HTTPFound)
def test_post_changing_password_with_valid_data_updates_password(self, req, user): req.POST = {'__formid__': 'password'} controller = views.ProfileController(req) controller.forms['password'] = form_validating_to( {'new_password': '******'}) controller.post() assert user.password == 'secrets!'
def test_post_changing_email_with_valid_data_redirects(self, req): req.POST = {'__formid__': 'email'} controller = views.ProfileController(req) controller.forms['email'] = form_validating_to( {'email': '*****@*****.**'}) result = controller.post() assert isinstance(result, httpexceptions.HTTPFound)
def test_post_changing_email_with_valid_data_updates_email(self, req, user): req.POST = {'__formid__': 'email'} controller = views.ProfileController(req) controller.forms['email'] = form_validating_to( {'email': '*****@*****.**'}) controller.post() assert user.email == '*****@*****.**'
def test_post_changing_password_with_invalid_data_returns_form(self): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'password'}, authenticated_user=user) controller = views.ProfileController(request) controller.forms['password'] = invalid_form() result = controller.post() assert 'password_form' in result
def test_post_changing_email_with_invalid_data_does_not_update_email(self): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'email'}, authenticated_user=user) controller = views.ProfileController(request) controller.forms['email'] = invalid_form() controller.post() assert user.email is None
def test_post_changing_password_with_valid_data_redirects(self): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'password'}, authenticated_user=user) controller = views.ProfileController(request) controller.forms['password'] = form_validating_to( {'new_password': '******'}) result = controller.post() assert isinstance(result, httpexceptions.HTTPFound)
def test_post_changing_password_with_valid_data_updates_password(self): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'password'}, authenticated_user=user) controller = views.ProfileController(request) controller.forms['password'] = form_validating_to( {'new_password': '******'}) controller.post() assert user.password == 'secrets!'
def test_post_changing_email_with_valid_data_updates_email(self): user = FakeUser(email=None, password=None) request = DummyRequest(post={'__formid__': 'email'}, authenticated_user=user) controller = views.ProfileController(request) controller.forms['email'] = form_validating_to( {'email': '*****@*****.**'}) controller.post() assert user.email == '*****@*****.**'
def test_post_400s_with_bogus_formid(self, req): req.POST = {'__formid__': 'hax0rs'} with pytest.raises(httpexceptions.HTTPBadRequest): views.ProfileController(req).post()
def test_post_400s_with_no_formid(self, req): with pytest.raises(httpexceptions.HTTPBadRequest): views.ProfileController(req).post()