Remove the use of schedule_for in post_notifications.

Years ago we started to implement a way to schedule a notification. We hit a problem but we never came up with a good solution and the feature never made it back to the top of the priority list.

This PR removes the code for scheduled_for. There will be another PR to drop the scheduled_notifications table and remove the schedule_notifications service permission

Unfortunately, I don't think we can remove the `scheduled_for` attribute from the notification.serialized method because out clients might fail if something is missing. For now I have left it in but defaulted the value to None.
This commit is contained in:
Rebecca Law
2020-06-24 07:34:58 +01:00
parent d108c644bc
commit ce32e577b7
12 changed files with 34 additions and 178 deletions

View File

@@ -10,7 +10,6 @@ from sqlalchemy.orm.exc import NoResultFound
from app.dao.notifications_dao import (
dao_create_notification,
dao_created_scheduled_notification,
dao_delete_notifications_by_id,
dao_get_last_notification_added_for_job_id,
dao_get_notifications_by_recipient_or_reference,
@@ -36,7 +35,6 @@ from app.models import (
Job,
Notification,
NotificationHistory,
ScheduledNotification,
NOTIFICATION_STATUS_TYPES,
NOTIFICATION_STATUS_TYPES_FAILED,
NOTIFICATION_TEMPORARY_FAILURE,
@@ -449,7 +447,6 @@ def test_save_notification_with_no_job(sample_template, mmg_provider):
def test_get_notification_with_personalisation_by_id(sample_template):
notification = create_notification(template=sample_template,
scheduled_for='2017-05-05 14:15',
status='created')
notification_from_db = get_notification_with_personalisation(
sample_template.service.id,
@@ -457,7 +454,6 @@ def test_get_notification_with_personalisation_by_id(sample_template):
key_type=None
)
assert notification == notification_from_db
assert notification_from_db.scheduled_notification.scheduled_for == datetime(2017, 5, 5, 14, 15)
def test_get_notification_by_id_when_notification_exists(sample_notification):
@@ -1392,18 +1388,6 @@ def test_dao_get_notifications_by_reference(
assert results.items[0].id == letter.id
def test_dao_created_scheduled_notification(sample_notification):
scheduled_notification = ScheduledNotification(notification_id=sample_notification.id,
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, 15)
def test_dao_get_notifications_by_to_field_filters_status(sample_template):
notification = create_notification(
template=sample_template, to_field='+447700900855',