Ejemplo n.º 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'}
Ejemplo n.º 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'}
Ejemplo n.º 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)
Ejemplo n.º 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!'
Ejemplo n.º 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)
Ejemplo n.º 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!'
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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