mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-27 03:09:26 -04:00
Updated the serialization of Notification.scheduled_for to include minutes.
This commit is contained in:
@@ -424,13 +424,13 @@ def test_should_send_all_scheduled_notifications_to_deliver_queue(notify_db,
|
||||
sample_template, mocker):
|
||||
mocked = mocker.patch('app.celery.provider_tasks.deliver_sms')
|
||||
message_to_deliver = sample_notification(notify_db=notify_db, notify_db_session=notify_db_session,
|
||||
template=sample_template, scheduled_for="2017-05-01 13")
|
||||
template=sample_template, scheduled_for="2017-05-01 13:15")
|
||||
sample_notification(notify_db=notify_db, notify_db_session=notify_db_session,
|
||||
template=sample_template, scheduled_for="2017-05-01 10", status='delivered')
|
||||
template=sample_template, scheduled_for="2017-05-01 10:15", status='delivered')
|
||||
sample_notification(notify_db=notify_db, notify_db_session=notify_db_session,
|
||||
template=sample_template)
|
||||
sample_notification(notify_db=notify_db, notify_db_session=notify_db_session,
|
||||
template=sample_template, scheduled_for="2017-05-01 14")
|
||||
template=sample_template, scheduled_for="2017-05-01 14:15")
|
||||
|
||||
scheduled_notifications = dao_get_scheduled_notifications()
|
||||
assert len(scheduled_notifications) == 1
|
||||
|
||||
@@ -494,7 +494,7 @@ def sample_notification(
|
||||
scheduled_notification = ScheduledNotification(id=uuid.uuid4(),
|
||||
notification_id=notification.id,
|
||||
scheduled_for=datetime.strptime(scheduled_for,
|
||||
"%Y-%m-%d %H"))
|
||||
"%Y-%m-%d %H:%M"))
|
||||
if status != 'created':
|
||||
scheduled_notification.pending = False
|
||||
db.session.add(scheduled_notification)
|
||||
|
||||
@@ -720,7 +720,7 @@ def test_save_notification_with_no_job(sample_template, mmg_provider):
|
||||
def test_get_notification_by_id(notify_db, notify_db_session, sample_template):
|
||||
notification = sample_notification(notify_db=notify_db, notify_db_session=notify_db_session,
|
||||
template=sample_template,
|
||||
scheduled_for='2017-05-05 14',
|
||||
scheduled_for='2017-05-05 14:15',
|
||||
status='created')
|
||||
notification_from_db = get_notification_with_personalisation(
|
||||
sample_template.service.id,
|
||||
@@ -728,7 +728,7 @@ def test_get_notification_by_id(notify_db, notify_db_session, sample_template):
|
||||
key_type=None
|
||||
)
|
||||
assert notification == notification_from_db
|
||||
assert notification_from_db.scheduled_notification.scheduled_for == datetime(2017, 5, 5, 14)
|
||||
assert notification_from_db.scheduled_notification.scheduled_for == datetime(2017, 5, 5, 14, 15)
|
||||
|
||||
|
||||
def test_get_notifications_by_reference(notify_db, notify_db_session, sample_service):
|
||||
@@ -1760,20 +1760,21 @@ def test_dao_get_notifications_by_to_field_search_ignores_spaces(sample_template
|
||||
def test_dao_created_scheduled_notification(sample_notification):
|
||||
|
||||
scheduled_notification = ScheduledNotification(notification_id=sample_notification.id,
|
||||
scheduled_for=datetime.strptime("2017-01-05 14", "%Y-%m-%d %H"))
|
||||
scheduled_for=datetime.strptime("2017-01-05 14:15",
|
||||
"%Y-%m-%d %H:%M"))
|
||||
dao_created_scheduled_notification(scheduled_notification)
|
||||
saved_notification = ScheduledNotification.query.all()
|
||||
assert len(saved_notification) == 1
|
||||
assert saved_notification[0].notification_id == sample_notification.id
|
||||
assert saved_notification[0].scheduled_for == datetime(2017, 1, 5, 14)
|
||||
assert saved_notification[0].scheduled_for == datetime(2017, 1, 5, 14, 15)
|
||||
|
||||
|
||||
def test_dao_get_scheduled_notifications(notify_db, notify_db_session, sample_template):
|
||||
notification_1 = sample_notification(notify_db=notify_db, notify_db_session=notify_db_session,
|
||||
template=sample_template, scheduled_for='2017-05-05 14',
|
||||
template=sample_template, scheduled_for='2017-05-05 14:15',
|
||||
status='created')
|
||||
sample_notification(notify_db=notify_db, notify_db_session=notify_db_session,
|
||||
template=sample_template, scheduled_for='2017-05-04 14', status='delivered')
|
||||
template=sample_template, scheduled_for='2017-05-04 14:15', status='delivered')
|
||||
sample_notification(notify_db=notify_db, notify_db_session=notify_db_session,
|
||||
template=sample_template, status='created')
|
||||
scheduled_notifications = dao_get_scheduled_notifications()
|
||||
@@ -1784,7 +1785,7 @@ def test_dao_get_scheduled_notifications(notify_db, notify_db_session, sample_te
|
||||
|
||||
def test_set_scheduled_notification_to_processed(notify_db, notify_db_session, sample_template):
|
||||
notification_1 = sample_notification(notify_db=notify_db, notify_db_session=notify_db_session,
|
||||
template=sample_template, scheduled_for='2017-05-05 14',
|
||||
template=sample_template, scheduled_for='2017-05-05 14:15',
|
||||
status='created')
|
||||
scheduled_notifications = dao_get_scheduled_notifications()
|
||||
assert len(scheduled_notifications) == 1
|
||||
|
||||
@@ -40,7 +40,7 @@ def test_get_utc_in_bst_returns_expected_date(date, expected_date):
|
||||
|
||||
|
||||
def test_convert_bst_to_utc():
|
||||
bst = "2017-05-12 13"
|
||||
bst_datetime = datetime.strptime(bst, "%Y-%m-%d %H")
|
||||
bst = "2017-05-12 13:15"
|
||||
bst_datetime = datetime.strptime(bst, "%Y-%m-%d %H:%M")
|
||||
utc = convert_bst_to_utc(bst_datetime)
|
||||
assert utc == datetime(2017, 5, 12, 12, 0)
|
||||
assert utc == datetime(2017, 5, 12, 12, 15)
|
||||
|
||||
@@ -20,12 +20,12 @@ def test_get_notification_by_id_returns_200(
|
||||
):
|
||||
sample_notification = create_sample_notification(
|
||||
notify_db, notify_db_session, billable_units=billable_units, sent_by=provider,
|
||||
scheduled_for="2017-05-12 14"
|
||||
scheduled_for="2017-05-12 15:15"
|
||||
)
|
||||
|
||||
another = create_sample_notification(
|
||||
notify_db, notify_db_session, billable_units=billable_units, sent_by=provider,
|
||||
scheduled_for="2017-06-12 14"
|
||||
scheduled_for="2017-06-12 15:15"
|
||||
)
|
||||
auth_header = create_authorization_header(service_id=sample_notification.service_id)
|
||||
response = client.get(
|
||||
@@ -63,7 +63,7 @@ def test_get_notification_by_id_returns_200(
|
||||
"subject": None,
|
||||
'sent_at': sample_notification.sent_at,
|
||||
'completed_at': sample_notification.completed_at(),
|
||||
'scheduled_for': '2017-05-12 14'
|
||||
'scheduled_for': '2017-05-12 14:15'
|
||||
}
|
||||
|
||||
assert json_response == expected_response
|
||||
@@ -139,7 +139,7 @@ def test_get_notification_by_reference_returns_200(client, notify_db, notify_db_
|
||||
|
||||
def test_get_notifications_returns_scheduled_for(client, notify_db, notify_db_session):
|
||||
sample_notification_with_reference = create_sample_notification(
|
||||
notify_db, notify_db_session, client_reference='some-client-reference', scheduled_for='2017-05-23 16')
|
||||
notify_db, notify_db_session, client_reference='some-client-reference', scheduled_for='2017-05-23 17:15')
|
||||
|
||||
auth_header = create_authorization_header(service_id=sample_notification_with_reference.service_id)
|
||||
response = client.get(
|
||||
@@ -153,7 +153,7 @@ def test_get_notifications_returns_scheduled_for(client, notify_db, notify_db_se
|
||||
assert len(json_response['notifications']) == 1
|
||||
|
||||
assert json_response['notifications'][0]['id'] == str(sample_notification_with_reference.id)
|
||||
assert json_response['notifications'][0]['scheduled_for'] == "2017-05-23 16"
|
||||
assert json_response['notifications'][0]['scheduled_for'] == "2017-05-23 16:15"
|
||||
|
||||
|
||||
def test_get_notification_by_reference_nonexistent_reference_returns_no_notifications(client, sample_service):
|
||||
|
||||
Reference in New Issue
Block a user