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)