Re-implement forgot password

This commit is contained in:
Rebecca Law
2016-03-07 18:18:52 +00:00
parent 8a46031203
commit 3e969b3640
8 changed files with 105 additions and 96 deletions

View File

@@ -9,13 +9,10 @@ def test_should_render_forgot_password(app_):
in response.get_data(as_text=True)
def test_should_redirect_to_password_reset_sent_and_state_updated(
app_,
api_user_active,
mock_get_user_by_email,
mock_update_user,
mock_send_email
):
def test_should_redirect_to_password_reset_sent_for_valid_email(
app_,
api_user_active,
mock_reset_user_password):
with app_.test_request_context():
response = app_.test_client().post(
url_for('.forgot_password'),
@@ -24,23 +21,4 @@ def test_should_redirect_to_password_reset_sent_and_state_updated(
assert (
'You have been sent an email containing a link'
' to reset your password.') in response.get_data(as_text=True)
assert mock_send_email.call_count == 1
def test_should_redirect_to_password_reset_sent_for_non_existant_email_address(
app_,
api_user_active,
mock_dont_get_user_by_email,
mock_update_user,
mock_send_email
):
with app_.test_request_context():
response = app_.test_client().post(
url_for('.forgot_password'),
data={'email_address': 'nope@example.gov.uk'})
assert response.status_code == 200
assert (
'You have been sent an email containing a link'
' to reset your password.') in response.get_data(as_text=True)
mock_dont_get_user_by_email.assert_called_once_with('nope@example.gov.uk')
assert not mock_send_email.called
mock_reset_user_password.assert_called_once_with(api_user_active.email_address)