Fixed up dates so that we respect mills

This commit is contained in:
Martyn Inglis
2016-03-08 17:45:37 +00:00
parent 67c4bd2263
commit e07d16e8c6
5 changed files with 37 additions and 34 deletions

View File

@@ -2,7 +2,7 @@ import uuid
import pytest
from flask import current_app
from app.celery.tasks import (send_sms, send_sms_code, send_email_code, send_email, process_job, email_invited_user)
from app import (firetext_client, aws_ses_client, encryption)
from app import (firetext_client, aws_ses_client, encryption, DATETIME_FORMAT)
from app.clients.email.aws_ses import AwsSesClientException
from app.clients.sms.firetext import FiretextClientException
from app.dao import notifications_dao, jobs_dao
@@ -34,7 +34,7 @@ def test_should_process_sms_job(sample_job, mocker):
(str(sample_job.service_id),
"uuid",
"something_encrypted",
"2016-01-01 11:09:00.061258"),
"2016-01-01T11:09:00.061258"),
queue="bulk-sms"
)
job = jobs_dao.dao_get_job_by_id(sample_job.id)
@@ -69,7 +69,7 @@ def test_should_process_email_job(sample_email_job, mocker):
sample_email_job.template.subject,
"{}@{}".format(sample_email_job.service.email_from, "test.notify.com"),
"something_encrypted",
"2016-01-01 11:09:00.061258"),
"2016-01-01T11:09:00.061258"),
queue="bulk-email"
)
job = jobs_dao.dao_get_job_by_id(sample_email_job.id)
@@ -106,7 +106,7 @@ def test_should_send_template_to_correct_sms_provider_and_persist(sample_templat
sample_template_with_placeholders.service_id,
notification_id,
"encrypted-in-reality",
now
now.strftime(DATETIME_FORMAT)
)
firetext_client.send_sms.assert_called_once_with("+441234123123", "Sample service: Hello Jo")
@@ -138,7 +138,7 @@ def test_should_send_sms_without_personalisation(sample_template, mocker):
sample_template.service_id,
notification_id,
"encrypted-in-reality",
now
now.strftime(DATETIME_FORMAT)
)
firetext_client.send_sms.assert_called_once_with("+441234123123", "Sample service: This is a template")
@@ -164,7 +164,7 @@ def test_should_send_sms_if_restricted_service_and_valid_number(notify_db, notif
service.id,
notification_id,
"encrypted-in-reality",
now
now.strftime(DATETIME_FORMAT)
)
firetext_client.send_sms.assert_called_once_with("+441234123123", "Sample service: This is a template")
@@ -190,7 +190,7 @@ def test_should_not_send_sms_if_restricted_service_and_invalid_number(notify_db,
service.id,
notification_id,
"encrypted-in-reality",
now
now.strftime(DATETIME_FORMAT)
)
firetext_client.send_sms.assert_not_called()
@@ -217,7 +217,8 @@ def test_should_send_email_if_restricted_service_and_valid_email(notify_db, noti
'subject',
'email_from',
"encrypted-in-reality",
now)
now.strftime(DATETIME_FORMAT)
)
aws_ses_client.send_email.assert_called_once_with(
"email_from",
@@ -243,8 +244,8 @@ def test_should_send_template_to_correct_sms_provider_and_persist_with_job_id(sa
sample_job.service.id,
notification_id,
"encrypted-in-reality",
now)
now.strftime(DATETIME_FORMAT)
)
firetext_client.send_sms.assert_called_once_with("+441234123123", "Sample service: This is a template")
persisted_notification = notifications_dao.get_notification(sample_job.template.service_id, notification_id)
assert persisted_notification.id == notification_id
@@ -275,8 +276,8 @@ def test_should_use_email_template_and_persist(sample_email_template_with_placeh
'subject',
'email_from',
"encrypted-in-reality",
now)
now.strftime(DATETIME_FORMAT)
)
aws_ses_client.send_email.assert_called_once_with(
"email_from",
"my_email@my_email.com",
@@ -313,8 +314,8 @@ def test_should_use_email_template_and_persist_without_personalisation(
'subject',
'email_from',
"encrypted-in-reality",
now)
now.strftime(DATETIME_FORMAT)
)
aws_ses_client.send_email.assert_called_once_with(
"email_from",
"my_email@my_email.com",
@@ -339,8 +340,8 @@ def test_should_persist_notification_as_failed_if_sms_client_fails(sample_templa
sample_template.service_id,
notification_id,
"encrypted-in-reality",
now)
now.strftime(DATETIME_FORMAT)
)
firetext_client.send_sms.assert_called_once_with("+441234123123", "Sample service: This is a template")
persisted_notification = notifications_dao.get_notification(sample_template.service_id, notification_id)
assert persisted_notification.id == notification_id
@@ -371,8 +372,8 @@ def test_should_persist_notification_as_failed_if_email_client_fails(sample_emai
'subject',
'email_from',
"encrypted-in-reality",
now)
now.strftime(DATETIME_FORMAT)
)
aws_ses_client.send_email.assert_called_once_with(
"email_from",
"my_email@my_email.com",
@@ -405,8 +406,8 @@ def test_should_not_send_sms_if_db_peristance_failed(sample_template, mocker):
sample_template.service_id,
notification_id,
"encrypted-in-reality",
now)
now.strftime(DATETIME_FORMAT)
)
firetext_client.send_sms.assert_not_called()
with pytest.raises(NoResultFound) as e:
notifications_dao.get_notification(sample_template.service_id, notification_id)
@@ -431,8 +432,8 @@ def test_should_not_send_email_if_db_peristance_failed(sample_email_template, mo
'subject',
'email_from',
"encrypted-in-reality",
now)
now.strftime(DATETIME_FORMAT)
)
aws_ses_client.send_email.assert_not_called()
with pytest.raises(NoResultFound) as e:
notifications_dao.get_notification(sample_email_template.service_id, notification_id)

View File

@@ -359,7 +359,7 @@ def test_send_notification_with_placeholders_replaced(notify_api, sample_templat
(str(sample_template_with_placeholders.service.id),
notification_id,
"something_encrypted",
"2016-01-01 11:09:00.061258"),
"2016-01-01T11:09:00.061258"),
queue="sms"
)
assert response.status_code == 201
@@ -525,7 +525,7 @@ def test_should_allow_valid_sms_notification(notify_api, sample_template, mocker
(str(sample_template.service_id),
notification_id,
"something_encrypted",
"2016-01-01 11:09:00.061258"),
"2016-01-01T11:09:00.061258"),
queue="sms"
)
assert response.status_code == 201
@@ -747,7 +747,7 @@ def test_should_allow_valid_email_notification(notify_api, sample_email_template
"Email Subject",
"sample.service@test.notify.com",
"something_encrypted",
"2016-01-01 11:09:00.061258"),
"2016-01-01T11:09:00.061258"),
queue="email"
)
assert response.status_code == 201