The regex to validate uuids was not rejecting uuids with a space at the end.

Switched to using a isinstance check on the string.
Added an order by clause to dao_get_template_usage_stats_by_service, it was causing an itermitten failure in the tests.
This commit is contained in:
Rebecca Law
2018-02-15 13:34:06 +00:00
parent de11751919
commit 52bf6dabcd
4 changed files with 35 additions and 2 deletions

View File

@@ -115,6 +115,30 @@ def test_post_sms_schema_is_valid(input):
assert validate(input, post_sms_request_schema) == input
@pytest.mark.parametrize("template_id",
['2ebe4da8-17be-49fe-b02f-dff2760261a0' + "\n",
'2ebe4da8-17be-49fe-b02f-dff2760261a0' + " ",
'2ebe4da8-17be-49fe-b02f-dff2760261a0' + "\r",
"\t" + '2ebe4da8-17be-49fe-b02f-dff2760261a0',
'2ebe4da8-17be-49fe-b02f-dff2760261a0'[4:],
"bad_uuid"
]
)
def test_post_sms_json_schema_bad_uuid(template_id):
j = {
"template_id": template_id,
"phone_number": "07515111111"
}
with pytest.raises(ValidationError) as e:
validate(j, post_sms_request_schema)
error = json.loads(str(e.value))
assert len(error.keys()) == 2
assert error.get('status_code') == 400
assert len(error.get('errors')) == 1
assert {'error': 'ValidationError',
'message': "template_id is not a valid UUID"} in error['errors']
def test_post_sms_json_schema_bad_uuid_and_missing_phone_number():
j = {"template_id": "notUUID"}
with pytest.raises(ValidationError) as e: