Remove custom error message from personalisation validation

There's no longer a single err msg that fits all problems with
personalisation - since letters expect specific fields there
This commit is contained in:
Leo Hemsted
2017-07-27 16:49:37 +01:00
parent 2ab105aaf4
commit 11f8603319
4 changed files with 33 additions and 7 deletions

View File

@@ -127,7 +127,7 @@ def test_post_sms_schema_with_personalisation_that_is_not_a_dict():
error = json.loads(str(e.value))
assert len(error.get('errors')) == 1
assert error['errors'] == [{'error': 'ValidationError',
'message': "personalisation should contain key value pairs"}]
'message': "personalisation not_a_dict is not of type object"}]
assert error.get('status_code') == 400
assert len(error.keys()) == 2

View File

@@ -100,6 +100,26 @@ def test_notification_returns_400_for_schema_problems(
}]
def test_notification_returns_400_if_address_doesnt_have_underscores(
client,
sample_letter_template
):
data = {
'template_id': str(sample_letter_template.id),
'personalisation': {
'address line 1': 'Her Royal Highness Queen Elizabeth II',
'postcode': 'SW1 1AA',
}
}
error_json = letter_request(client, data, service_id=sample_letter_template.service_id, _expected_status=400)
assert error_json['status_code'] == 400
assert error_json['errors'] == [{
'error': 'ValidationError',
'message': 'personalisation address_line_1 is a required property'
}]
def test_returns_a_429_limit_exceeded_if_rate_limit_exceeded(
client,

View File

@@ -51,11 +51,18 @@ valid_json_post_args = {
}
invalid_json_post_args = [
({"id": "invalid_uuid", "personalisation": {"key": "value"}}, ["id is not a valid UUID"]),
({"id": str(uuid.uuid4()), "personalisation": "invalid_personalisation"},
["personalisation should contain key value pairs"]),
({"personalisation": "invalid_personalisation"},
["id is a required property", "personalisation should contain key value pairs"])
(
{"id": "invalid_uuid", "personalisation": {"key": "value"}},
["id is not a valid UUID"]
),
(
{"id": str(uuid.uuid4()), "personalisation": ['a', 'b']},
["personalisation [a, b] is not of type object"]
),
(
{"personalisation": "invalid_personalisation"},
["id is a required property", "personalisation invalid_personalisation is not of type object"]
)
]
valid_json_post_response = {