From c1fa5e156a87276ca6aacb0341928bf2f95364bb Mon Sep 17 00:00:00 2001 From: Paul Craig Date: Mon, 21 Nov 2016 15:16:21 +0000 Subject: [PATCH] Append "Z" to DATETIME_FORMAT We're formally using the ISO 8601 UTC datetime format, and so the correct way to output the data is by appending the timezone. ("Z" in the case of UTC*). Unfortunately, Python's `datetime` formatting will just ignore the timezone part of the string on output, which means we just have to append the string "Z" to the end of all datetime strings we output. Should be fine, as we will only ever output UTC timestamps anyway. * https://en.wikipedia.org/wiki/ISO_8601#UTC --- app/__init__.py | 2 +- tests/app/celery/test_tasks.py | 10 +++++----- tests/app/invite/test_invite_rest.py | 2 +- tests/app/user/test_rest.py | 6 +++--- tests/app/user/test_rest_verify.py | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index e42bb7dc8..73082d14e 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -18,7 +18,7 @@ from app.clients.statsd.statsd_client import StatsdClient from app.encryption import Encryption -DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f" +DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ" DATE_FORMAT = "%Y-%m-%d" db = SQLAlchemy() diff --git a/tests/app/celery/test_tasks.py b/tests/app/celery/test_tasks.py index da4d5201c..f3654a8ef 100644 --- a/tests/app/celery/test_tasks.py +++ b/tests/app/celery/test_tasks.py @@ -76,7 +76,7 @@ def test_should_process_sms_job(sample_job, mocker): (str(sample_job.service_id), "uuid", "something_encrypted", - "2016-01-01T11:09:00.061258"), + "2016-01-01T11:09:00.061258Z"), queue="db-sms" ) job = jobs_dao.dao_get_job_by_id(sample_job.id) @@ -104,7 +104,7 @@ def test_should_process_sms_job_into_research_mode_queue_if_research_mode_servic (str(job.service_id), "uuid", "something_encrypted", - "2016-01-01T11:09:00.061258"), + "2016-01-01T11:09:00.061258Z"), queue="research-mode" ) @@ -133,7 +133,7 @@ def test_should_process_email_job_into_research_mode_queue_if_research_mode_serv (str(job.service_id), "uuid", "something_encrypted", - "2016-01-01T11:09:00.061258"), + "2016-01-01T11:09:00.061258Z"), queue="research-mode" ) @@ -252,7 +252,7 @@ def test_should_process_email_job_if_exactly_on_send_limits(notify_db, str(job.service_id), "uuid", "something_encrypted", - "2016-01-01T11:09:00.061258" + "2016-01-01T11:09:00.061258Z" ), queue="db-email" ) @@ -294,7 +294,7 @@ def test_should_process_email_job(sample_email_job, mocker): str(sample_email_job.service_id), "uuid", "something_encrypted", - "2016-01-01T11:09:00.061258" + "2016-01-01T11:09:00.061258Z" ), queue="db-email" ) diff --git a/tests/app/invite/test_invite_rest.py b/tests/app/invite/test_invite_rest.py index 9cf9c2f13..f76296d8c 100644 --- a/tests/app/invite/test_invite_rest.py +++ b/tests/app/invite/test_invite_rest.py @@ -55,7 +55,7 @@ def test_create_invited_user(notify_api, sample_service, mocker, invitation_emai (str(current_app.config['NOTIFY_SERVICE_ID']), 'some_uuid', encryption.encrypt(message), - "2016-01-01T11:09:00.061258"), + "2016-01-01T11:09:00.061258Z"), queue="notify") diff --git a/tests/app/user/test_rest.py b/tests/app/user/test_rest.py index 8c87893aa..a6513e0f9 100644 --- a/tests/app/user/test_rest.py +++ b/tests/app/user/test_rest.py @@ -445,7 +445,7 @@ def test_send_user_reset_password_should_send_reset_password_link(notify_api, [str(current_app.config['NOTIFY_SERVICE_ID']), 'some_uuid', app.encryption.encrypt(message), - "2016-01-01T11:09:00.061258"], + "2016-01-01T11:09:00.061258Z"], queue="notify") @@ -525,7 +525,7 @@ def test_send_already_registered_email(notify_api, sample_user, already_register (str(current_app.config['NOTIFY_SERVICE_ID']), 'some_uuid', app.encryption.encrypt(message), - "2016-01-01T11:09:00.061258"), + "2016-01-01T11:09:00.061258Z"), queue="notify") @@ -573,7 +573,7 @@ def test_send_user_confirm_new_email_returns_204(notify_api, sample_user, change str(current_app.config['NOTIFY_SERVICE_ID']), "some_uuid", app.encryption.encrypt(message), - "2016-01-01T11:09:00.061258"), queue="notify") + "2016-01-01T11:09:00.061258Z"), queue="notify") def test_send_user_confirm_new_email_returns_400_when_email_missing(notify_api, sample_user, mocker): diff --git a/tests/app/user/test_rest_verify.py b/tests/app/user/test_rest_verify.py index f38575b55..006247292 100644 --- a/tests/app/user/test_rest_verify.py +++ b/tests/app/user/test_rest_verify.py @@ -248,7 +248,7 @@ def test_send_user_sms_code(notify_api, ([current_app.config['NOTIFY_SERVICE_ID'], "some_uuid", encrypted, - "2016-01-01T11:09:00.061258"]), + "2016-01-01T11:09:00.061258Z"]), queue="notify" ) @@ -288,7 +288,7 @@ def test_send_user_code_for_sms_with_optional_to_field(notify_api, ([current_app.config['NOTIFY_SERVICE_ID'], "some_uuid", encrypted, - "2016-01-01T11:09:00.061258"]), + "2016-01-01T11:09:00.061258Z"]), queue="notify" ) @@ -343,7 +343,7 @@ def test_send_user_email_verification(notify_api, (str(current_app.config['NOTIFY_SERVICE_ID']), 'some_uuid', encryption.encrypt(message), - "2016-01-01T11:09:00.061258"), + "2016-01-01T11:09:00.061258Z"), queue="notify")