From fb36404b6c5a8843c3ca348a52002471f8263a6e Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Wed, 12 Aug 2020 18:30:00 +0100 Subject: [PATCH] Fix error message when invitation has expired The error message for when an invitation to Notify had expired was displaying in admin with square brackets round it because admin is not expecting the message to be a list (https://github.com/alphagov/notifications-admin/blob/a85134ee227a89fbe13ee470a7b74b69e01ad7e2/app/models/user.py#L500) --- app/accept_invite/rest.py | 4 ++-- tests/app/accept_invite/test_accept_invite_rest.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/accept_invite/rest.py b/app/accept_invite/rest.py index a6ac0773b..0485fc58a 100644 --- a/app/accept_invite/rest.py +++ b/app/accept_invite/rest.py @@ -35,8 +35,8 @@ def validate_invitation_token(invitation_type, token): max_age_seconds) except SignatureExpired: errors = {'invitation': - ['Your invitation to GOV.UK Notify has expired. ' - 'Please ask the person that invited you to send you another one']} + 'Your invitation to GOV.UK Notify has expired. ' + 'Please ask the person that invited you to send you another one'} raise InvalidRequest(errors, status_code=400) except BadData: errors = {'invitation': 'Something’s wrong with this link. Make sure you’ve copied the whole thing.'} diff --git a/tests/app/accept_invite/test_accept_invite_rest.py b/tests/app/accept_invite/test_accept_invite_rest.py index f0c806473..a351eb4de 100644 --- a/tests/app/accept_invite/test_accept_invite_rest.py +++ b/tests/app/accept_invite/test_accept_invite_rest.py @@ -19,9 +19,9 @@ def test_validate_invitation_token_for_expired_token_returns_400(client, invitat assert response.status_code == 400 json_resp = json.loads(response.get_data(as_text=True)) assert json_resp['result'] == 'error' - assert json_resp['message'] == {'invitation': [ - 'Your invitation to GOV.UK Notify has expired. ' - 'Please ask the person that invited you to send you another one']} + assert json_resp['message'] == { + 'invitation': 'Your invitation to GOV.UK Notify has expired. ' + 'Please ask the person that invited you to send you another one'} @pytest.mark.parametrize('invitation_type', ['service', 'organisation'])