Skip to content

Commit

Permalink
Append "Z" to DATETIME_FORMAT
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pcraig3 committed Nov 21, 2016
1 parent 82ba2cd commit c1fa5e1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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()
Expand Down
10 changes: 5 additions & 5 deletions tests/app/celery/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
)

Expand Down Expand Up @@ -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"
)

Expand Down Expand Up @@ -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"
)
Expand Down Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/app/invite/test_invite_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
6 changes: 3 additions & 3 deletions tests/app/user/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down Expand Up @@ -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")


Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tests/app/user/test_rest_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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"
)

Expand Down Expand Up @@ -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")


Expand Down

0 comments on commit c1fa5e1

Please sign in to comment.