From a8edfeb94144d851370f8af8d6419d737e8fb878 Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Thu, 9 Dec 2021 10:46:19 +0000 Subject: [PATCH] Remove command to replay callbacks In response to [1]. I've already removed the runbook that referred to this. [1]: https://github.com/alphagov/notifications-api/pull/3383#discussion_r765644576 --- app/commands.py | 20 -------------------- tests/app/test_commands.py | 28 +--------------------------- 2 files changed, 1 insertion(+), 47 deletions(-) diff --git a/app/commands.py b/app/commands.py index 1b8230922..565b83bde 100644 --- a/app/commands.py +++ b/app/commands.py @@ -78,9 +78,6 @@ from app.models import ( Service, User, ) -from app.notifications.notifications_ses_callback import ( - check_and_queue_callback_task, -) from app.utils import get_london_midnight_in_utc @@ -280,23 +277,6 @@ def recreate_pdf_for_precompiled_or_uploaded_letter(notification_id): resanitise_pdf.apply_async([str(notification_id)], queue=QueueNames.LETTERS) -@notify_command(name='replay-callbacks') -@click.option('-f', '--file-name', required=True, - help="""Full path of the file to upload, containing IDs of - notifications that need the status to be sent to the service.""") -def replay_callbacks(file_name): - print("Replaying callbacks.") - file = open(file_name) - - for id in [id.strip() for id in file]: - try: - notification = Notification.query.filter_by(id=id).one() - check_and_queue_callback_task(notification) - print(f"Created callback task for notification: {id}.") - except NoResultFound: - print(f"ID: {id} was not found in notifications.") - - def setup_commands(application): application.cli.add_command(command_group) diff --git a/tests/app/test_commands.py b/tests/app/test_commands.py index aef033ca5..dd8f1c15b 100644 --- a/tests/app/test_commands.py +++ b/tests/app/test_commands.py @@ -1,6 +1,4 @@ -import uuid - -from app.commands import local_dev_broadcast_permissions, replay_callbacks +from app.commands import local_dev_broadcast_permissions from app.dao.services_dao import dao_add_user_to_service from tests.app.db import create_user @@ -23,27 +21,3 @@ def test_local_dev_broadcast_permissions( assert len(user.get_permissions(sample_service.id)) == 0 assert len(user.get_permissions(sample_broadcast_service.id)) > 0 - - -def test_replay_callbacks( - mocker, - sample_service, - sample_notification, - tmpdir, - notify_api, -): - mock_task = mocker.patch('app.commands.check_and_queue_callback_task') - file_path = tmpdir + 'callback_ids.txt' - missing_notification_id = uuid.uuid4() - - with open(file_path, 'w') as f: - f.write(str(sample_notification.id) + "\n") - f.write(str(missing_notification_id) + "\n") - - result = notify_api.test_cli_runner().invoke( - replay_callbacks, ['-f', file_path] - ) - - assert f'{missing_notification_id} was not found' in result.output - mock_task.assert_called_once_with(sample_notification) - assert result.exit_code == 0