예제 #1
0
    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()
예제 #2
0
    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
예제 #3
0
    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
예제 #4
0
    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
예제 #5
0
    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)
예제 #6
0
    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!'
예제 #7
0
    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)
예제 #8
0
    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 == '*****@*****.**'
예제 #9
0
    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
예제 #10
0
    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
예제 #11
0
    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)
예제 #12
0
    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!'
예제 #13
0
    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 == '*****@*****.**'
예제 #14
0
    def test_post_400s_with_bogus_formid(self, req):
        req.POST = {'__formid__': 'hax0rs'}

        with pytest.raises(httpexceptions.HTTPBadRequest):
            views.ProfileController(req).post()
예제 #15
0
 def test_post_400s_with_no_formid(self, req):
     with pytest.raises(httpexceptions.HTTPBadRequest):
         views.ProfileController(req).post()