From d8a0a3f5ab8510e4cc5858201189f28317fa1d38 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Thu, 20 Dec 2018 17:02:49 +0000 Subject: [PATCH] Added a test to make sure the loop exits. --- .../test_notification_dao_delete_notifications.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/app/dao/notification_dao/test_notification_dao_delete_notifications.py b/tests/app/dao/notification_dao/test_notification_dao_delete_notifications.py index 1479921bd..8c39c4ccb 100644 --- a/tests/app/dao/notification_dao/test_notification_dao_delete_notifications.py +++ b/tests/app/dao/notification_dao/test_notification_dao_delete_notifications.py @@ -186,6 +186,20 @@ def test_delete_notifications_does_try_to_delete_from_s3_when_letter_has_not_bee mock_get_s3.assert_not_called() +def test_delete_notifications_calls_subquery( + notify_db_session, mocker +): + service = create_service() + sms_template = create_template(service=service) + create_notification(template=sms_template, created_at=datetime.now() - timedelta(days=8)) + create_notification(template=sms_template, created_at=datetime.now() - timedelta(days=8)) + create_notification(template=sms_template, created_at=datetime.now() - timedelta(days=8)) + + assert Notification.query.count() == 3 + delete_notifications_created_more_than_a_week_ago_by_type('sms', qry_limit=1) + assert Notification.query.count() == 0 + + def _create_templates(sample_service): email_template = create_template(service=sample_service, template_type='email') sms_template = create_template(service=sample_service)