From ea8a3754a04995eb7841562224cd9b737c062a97 Mon Sep 17 00:00:00 2001 From: Ken Tsang Date: Wed, 15 Mar 2017 15:48:28 +0000 Subject: [PATCH] Updated schema to handle null updated_at --- app/v2/template/template_schemas.py | 2 +- tests/app/v2/template/test_template_schemas.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/v2/template/template_schemas.py b/app/v2/template/template_schemas.py index 8356dbd0e..fc727302b 100644 --- a/app/v2/template/template_schemas.py +++ b/app/v2/template/template_schemas.py @@ -29,7 +29,7 @@ get_template_by_id_response = { }, "updated_at": { "format": "date-time", - "type": "string", + "type": ["string", "null"], "description": "Date+time updated" }, "created_by": {"type": "string"}, diff --git a/tests/app/v2/template/test_template_schemas.py b/tests/app/v2/template/test_template_schemas.py index 9e946c2e2..3a89cf5e2 100644 --- a/tests/app/v2/template/test_template_schemas.py +++ b/tests/app/v2/template/test_template_schemas.py @@ -15,7 +15,7 @@ valid_json = { 'id': str(uuid.uuid4()), 'type': 'email', 'created_at': '2017-01-10T18:25:43.511Z', - 'updated_at': '2017-04-23T18:25:43.511Z', + 'updated_at': None, 'version': 1, 'created_by': 'someone@test.com', 'body': "some body" @@ -25,7 +25,7 @@ valid_json_with_optionals = { 'id': str(uuid.uuid4()), 'type': 'email', 'created_at': '2017-01-10T18:25:43.511Z', - 'updated_at': '2017-04-23T18:25:43.511Z', + 'updated_at': None, 'version': 1, 'created_by': 'someone', 'body': "some body", @@ -62,5 +62,9 @@ def test_get_template_request_schema_against_invalid_args_is_invalid(args, error @pytest.mark.parametrize("response", [valid_json, valid_json_with_optionals]) -def test_get_template_response_schema_is_valid(response): +@pytest.mark.parametrize("updated_datetime", [None, '2017-01-11T18:25:43.511Z']) +def test_get_template_response_schema_is_valid(response, updated_datetime): + if updated_datetime: + response['updated_at'] = updated_datetime + assert validate(response, get_template_by_id_response) == response