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
This commit is contained in:
Ben Thorner
2021-12-09 10:46:19 +00:00
parent ab4cb029df
commit a8edfeb941
2 changed files with 1 additions and 47 deletions

View File

@@ -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)

View File

@@ -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