From 4cf218f5c8d17cdf9b1336dd13d39545b4cdf5bc Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 4 May 2020 10:14:16 +0100 Subject: [PATCH] Add error messages for bad international addresses Template preview started putting these in the metadata of the S3 object in this pull request: https://github.com/alphagov/notifications-template-preview/pull/445 Specific error key is defined here: https://github.com/alphagov/notifications-template-preview/blob/800b48fce5b5846ac13d64719ac3bfa34d000f14/app/precompiled.py#L558 --- app/utils.py | 11 +++++++++++ tests/app/test_utils.py | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/app/utils.py b/app/utils.py index 1c8b69eb3..f8e5491f6 100644 --- a/app/utils.py +++ b/app/utils.py @@ -669,6 +669,17 @@ LETTER_VALIDATION_MESSAGES = { 'Validation failed because the last line of the address is not a real UK postcode.' ), }, + 'not-a-real-uk-postcode-or-country': { + 'title': 'There’s a problem with the address for this letter', + 'detail': ( + 'The last line of the address must be a UK postcode or ' + 'another country.' + ), + 'summary': ( + 'Validation failed because the last line of the address is ' + 'not a UK postcode or another country.' + ), + }, 'not-enough-address-lines': { 'title': 'There’s a problem with the address for this letter', 'detail': ( diff --git a/tests/app/test_utils.py b/tests/app/test_utils.py index 353d26626..6fae70a20 100644 --- a/tests/app/test_utils.py +++ b/tests/app/test_utils.py @@ -508,6 +508,19 @@ def test_get_letter_validation_error_for_unknown_error(): 'Validation failed because the last line of the address is not a real UK postcode.' ), ), + ( + 'not-a-real-uk-postcode-or-country', + None, + 'There’s a problem with the address for this letter', + ( + 'The last line of the address must be a UK postcode or ' + 'another country.' + ), + ( + 'Validation failed because the last line of the address is ' + 'not a UK postcode or another country.' + ), + ), ( 'not-enough-address-lines', None,