Exemple #1
0
def test_reset_password_returns_form_when_validation_fails():
    request = DummyRequest(method='POST')
    controller = ResetPasswordController(request)
    controller.form = invalid_form()

    result = controller.reset_password()

    assert result == {'form': 'invalid form'}
Exemple #2
0
def test_reset_password_returns_form_when_validation_fails():
    request = DummyRequest(method='POST')
    controller = ResetPasswordController(request)
    controller.form = invalid_form()

    result = controller.reset_password()

    assert result == {'form': 'invalid form'}
Exemple #3
0
def test_reset_password_redirects_on_success():
    request = DummyRequest(method='POST')
    user = FakeUser(password='******')
    controller = ResetPasswordController(request)
    controller.form = form_validating_to({'user': user,
                                          'password': '******'})

    result = controller.reset_password()

    assert isinstance(result, httpexceptions.HTTPRedirection)
Exemple #4
0
def test_reset_password_sets_user_password_from_form():
    request = DummyRequest(method='POST')
    elephant = FakeUser(password='******')
    controller = ResetPasswordController(request)
    controller.form = form_validating_to({'user': elephant,
                                          'password': '******'})

    controller.reset_password()

    assert elephant.password == 's3cure!'
Exemple #5
0
def test_reset_password_redirects_on_success():
    request = DummyRequest(method='POST')
    user = FakeUser(password='******')
    controller = ResetPasswordController(request)
    controller.form = form_validating_to({'user': user,
                                          'password': '******'})

    result = controller.reset_password()

    assert isinstance(result, httpexceptions.HTTPRedirection)
Exemple #6
0
def test_reset_password_sets_user_password_from_form():
    request = DummyRequest(method='POST')
    elephant = FakeUser(password='******')
    controller = ResetPasswordController(request)
    controller.form = form_validating_to({'user': elephant,
                                          'password': '******'})

    controller.reset_password()

    assert elephant.password == 's3cure!'
Exemple #7
0
def test_reset_password_emits_event(event, notify):
    request = DummyRequest(method='POST')
    user = FakeUser(password='******')
    controller = ResetPasswordController(request)
    controller.form = form_validating_to({'user': user,
                                          'password': '******'})

    controller.reset_password()

    event.assert_called_with(request, user)
    notify.assert_called_with(event.return_value)
Exemple #8
0
def test_reset_password_emits_event(event, notify):
    request = DummyRequest(method='POST')
    user = FakeUser(password='******')
    controller = ResetPasswordController(request)
    controller.form = form_validating_to({'user': user,
                                          'password': '******'})

    controller.reset_password()

    event.assert_called_with(request, user)
    notify.assert_called_with(event.return_value)
Exemple #9
0
def test_reset_password_deletes_activation():
    request = DummyRequest(method='POST')
    user = FakeUser(password='******')
    user.activation = mock.sentinel.activation
    controller = ResetPasswordController(request)
    controller.form = form_validating_to({'user': user,
                                          'password': '******'})

    controller.reset_password()

    assert mock.sentinel.activation in request.db.deleted