mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Allow the admin app to send one-off letters
This commit modifies the code paths the admin app uses to send one off emails and text messages to also accept letters. This mostly worked already, the two changes were: - making sure that one-off letters are processed by the correct task, from the correct queue - one-off letters sent from a service in research mode don’t get put on a queue and go straight to `delivered` (because we don’t want to send them for real)
This commit is contained in:
@@ -257,22 +257,35 @@ def test_persist_notification_increments_cache_if_key_exists(sample_template, sa
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('research_mode, requested_queue, expected_queue, notification_type, key_type',
|
||||
[(True, None, 'research-mode-tasks', 'sms', 'normal'),
|
||||
(True, None, 'research-mode-tasks', 'email', 'normal'),
|
||||
(True, None, 'research-mode-tasks', 'email', 'team'),
|
||||
(False, None, 'send-sms-tasks', 'sms', 'normal'),
|
||||
(False, None, 'send-email-tasks', 'email', 'normal'),
|
||||
(False, None, 'send-sms-tasks', 'sms', 'team'),
|
||||
(False, None, 'research-mode-tasks', 'sms', 'test'),
|
||||
(True, 'notify-internal-tasks', 'research-mode-tasks', 'email', 'normal'),
|
||||
(False, 'notify-internal-tasks', 'notify-internal-tasks', 'sms', 'normal'),
|
||||
(False, 'notify-internal-tasks', 'notify-internal-tasks', 'email', 'normal'),
|
||||
(False, 'notify-internal-tasks', 'research-mode-tasks', 'sms', 'test')])
|
||||
def test_send_notification_to_queue(notify_db, notify_db_session,
|
||||
research_mode, requested_queue, expected_queue,
|
||||
notification_type, key_type, mocker):
|
||||
mocked = mocker.patch('app.celery.provider_tasks.deliver_{}.apply_async'.format(notification_type))
|
||||
@pytest.mark.parametrize((
|
||||
'research_mode, requested_queue, notification_type, key_type, expected_queue, expected_task'
|
||||
), [
|
||||
(True, None, 'sms', 'normal', 'research-mode-tasks', 'provider_tasks.deliver_sms'),
|
||||
(True, None, 'email', 'normal', 'research-mode-tasks', 'provider_tasks.deliver_email'),
|
||||
(True, None, 'email', 'team', 'research-mode-tasks', 'provider_tasks.deliver_email'),
|
||||
(True, None, 'letter', 'normal', 'research-mode-tasks', 'letters_pdf_tasks.create_letters_pdf'),
|
||||
(False, None, 'sms', 'normal', 'send-sms-tasks', 'provider_tasks.deliver_sms'),
|
||||
(False, None, 'email', 'normal', 'send-email-tasks', 'provider_tasks.deliver_email'),
|
||||
(False, None, 'sms', 'team', 'send-sms-tasks', 'provider_tasks.deliver_sms'),
|
||||
(False, None, 'letter', 'normal', 'create-letters-pdf-tasks', 'letters_pdf_tasks.create_letters_pdf'),
|
||||
(False, None, 'sms', 'test', 'research-mode-tasks', 'provider_tasks.deliver_sms'),
|
||||
(True, 'notify-internal-tasks', 'email', 'normal', 'research-mode-tasks', 'provider_tasks.deliver_email'),
|
||||
(False, 'notify-internal-tasks', 'sms', 'normal', 'notify-internal-tasks', 'provider_tasks.deliver_sms'),
|
||||
(False, 'notify-internal-tasks', 'email', 'normal', 'notify-internal-tasks', 'provider_tasks.deliver_email'),
|
||||
(False, 'notify-internal-tasks', 'sms', 'test', 'research-mode-tasks', 'provider_tasks.deliver_sms'),
|
||||
])
|
||||
def test_send_notification_to_queue(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
research_mode,
|
||||
requested_queue,
|
||||
notification_type,
|
||||
key_type,
|
||||
expected_queue,
|
||||
expected_task,
|
||||
mocker,
|
||||
):
|
||||
mocked = mocker.patch('app.celery.{}.apply_async'.format(expected_task))
|
||||
Notification = namedtuple('Notification', ['id', 'key_type', 'notification_type', 'created_at'])
|
||||
notification = Notification(
|
||||
id=uuid.uuid4(),
|
||||
|
||||
Reference in New Issue
Block a user