示例#1
0
文件: views_test.py 项目: jasdeep/h
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
示例#2
0
文件: views_test.py 项目: jasdeep/h
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 == '*****@*****.**'
示例#3
0
文件: views_test.py 项目: jasdeep/h
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!'
示例#4
0
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
示例#5
0
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!'
示例#6
0
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 == '*****@*****.**'
示例#7
0
文件: views_test.py 项目: jasdeep/h
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
示例#8
0
文件: views_test.py 项目: jasdeep/h
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)
示例#9
0
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
示例#10
0
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)