From e2effb6ee1f5d6f0247768e835857a25e12d44b7 Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Fri, 13 Mar 2020 15:39:20 +0000 Subject: [PATCH] Update JSON schema postage validation for new values --- app/schema_validation/__init__.py | 4 ++-- tests/app/service/test_rest.py | 3 ++- tests/app/v2/notifications/test_post_letter_notifications.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/schema_validation/__init__.py b/app/schema_validation/__init__.py index e1995f528..0ddd51f16 100644 --- a/app/schema_validation/__init__.py +++ b/app/schema_validation/__init__.py @@ -34,8 +34,8 @@ def validate_schema_email_address(instance): @format_checker.checks('postage', raises=ValidationError) def validate_schema_postage(instance): if isinstance(instance, str): - if instance not in ["first", "second"]: - raise ValidationError("invalid. It must be either first or second.") + if instance not in ["first", "second", "europe", "rest-of-world"]: + raise ValidationError("invalid. It must be first, second, europe or rest-of-world.") return True diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index 637683453..bc1fc6955 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -2313,7 +2313,8 @@ def test_create_pdf_letter(mocker, sample_service_full_permissions, client, fake {"postage": "third", "filename": "string", "created_by": "string", "file_id": "string", "recipient_address": "Some Address"}, [ - {'error': 'ValidationError', 'message': 'postage invalid. It must be either first or second.'} + {'error': 'ValidationError', + 'message': 'postage invalid. It must be first, second, europe or rest-of-world.'} ] ) ]) diff --git a/tests/app/v2/notifications/test_post_letter_notifications.py b/tests/app/v2/notifications/test_post_letter_notifications.py index 305506d9f..b88621212 100644 --- a/tests/app/v2/notifications/test_post_letter_notifications.py +++ b/tests/app/v2/notifications/test_post_letter_notifications.py @@ -543,7 +543,7 @@ def test_post_letter_notification_throws_error_for_invalid_postage(client, notif assert response.status_code == 400, response.get_data(as_text=True) resp_json = json.loads(response.get_data(as_text=True)) - assert resp_json['errors'][0]['message'] == "postage invalid. It must be either first or second." + assert resp_json['errors'][0]['message'] == "postage invalid. It must be first, second, europe or rest-of-world." assert not Notification.query.first()