mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-02 12:48:32 -04:00
Update JSON schema postage validation for new values
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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.'}
|
||||
]
|
||||
)
|
||||
])
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user