mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-11 09:27:56 -04:00
notify-api-433b remove research mode
This commit is contained in:
@@ -10,7 +10,7 @@ from app.celery.process_ses_receipts_tasks import (
|
||||
remove_emails_from_bounce,
|
||||
remove_emails_from_complaint,
|
||||
)
|
||||
from app.celery.research_mode_tasks import (
|
||||
from app.celery.test_key_tasks import (
|
||||
ses_hard_bounce_callback,
|
||||
ses_notification_callback,
|
||||
ses_soft_bounce_callback,
|
||||
|
||||
@@ -275,19 +275,17 @@ def test_should_process_all_sms_job(sample_job_with_placeholdered_template,
|
||||
# -------------- process_row tests -------------- #
|
||||
|
||||
|
||||
@pytest.mark.parametrize('template_type, research_mode, expected_function, expected_queue', [
|
||||
(SMS_TYPE, False, 'save_sms', 'database-tasks'),
|
||||
(SMS_TYPE, True, 'save_sms', 'research-mode-tasks'),
|
||||
(EMAIL_TYPE, False, 'save_email', 'database-tasks'),
|
||||
(EMAIL_TYPE, True, 'save_email', 'research-mode-tasks'),
|
||||
@pytest.mark.parametrize('template_type, expected_function, expected_queue', [
|
||||
(SMS_TYPE, 'save_sms', 'database-tasks'),
|
||||
(EMAIL_TYPE, 'save_email', 'database-tasks'),
|
||||
])
|
||||
def test_process_row_sends_letter_task(template_type, research_mode, expected_function, expected_queue, mocker):
|
||||
def test_process_row_sends_letter_task(template_type, expected_function, expected_queue, mocker):
|
||||
mocker.patch('app.celery.tasks.create_uuid', return_value='noti_uuid')
|
||||
task_mock = mocker.patch('app.celery.tasks.{}.apply_async'.format(expected_function))
|
||||
encrypt_mock = mocker.patch('app.celery.tasks.encryption.encrypt')
|
||||
template = Mock(id='template_id', template_type=template_type)
|
||||
job = Mock(id='job_id', template_version='temp_vers')
|
||||
service = Mock(id='service_id', research_mode=research_mode)
|
||||
service = Mock(id='service_id')
|
||||
|
||||
process_row(
|
||||
Row(
|
||||
@@ -390,30 +388,6 @@ def test_should_send_template_to_correct_sms_task_and_persist(sample_template_wi
|
||||
)
|
||||
|
||||
|
||||
def test_should_put_save_sms_task_in_research_mode_queue_if_research_mode_service(notify_db_session, mocker):
|
||||
service = create_service(research_mode=True, )
|
||||
|
||||
template = create_template(service=service)
|
||||
|
||||
notification = _notification_json(template, to="+447234123123")
|
||||
|
||||
mocked_deliver_sms = mocker.patch('app.celery.provider_tasks.deliver_sms.apply_async')
|
||||
|
||||
notification_id = uuid.uuid4()
|
||||
|
||||
save_sms(
|
||||
template.service_id,
|
||||
notification_id,
|
||||
encryption.encrypt(notification),
|
||||
)
|
||||
persisted_notification = Notification.query.one()
|
||||
provider_tasks.deliver_sms.apply_async.assert_called_once_with(
|
||||
[str(persisted_notification.id)],
|
||||
queue="research-mode-tasks"
|
||||
)
|
||||
assert mocked_deliver_sms.called
|
||||
|
||||
|
||||
def test_should_save_sms_if_restricted_service_and_valid_number(notify_db_session, mocker):
|
||||
user = create_user(mobile_number="202-867-5309")
|
||||
service = create_service(user=user, restricted=True)
|
||||
@@ -518,32 +492,6 @@ def test_should_not_save_email_if_restricted_service_and_invalid_email_address(n
|
||||
assert Notification.query.count() == 0
|
||||
|
||||
|
||||
def test_should_put_save_email_task_in_research_mode_queue_if_research_mode_service(
|
||||
notify_db_session, mocker
|
||||
):
|
||||
service = create_service(research_mode=True)
|
||||
|
||||
template = create_template(service=service, template_type='email')
|
||||
|
||||
notification = _notification_json(template, to="test@test.com")
|
||||
|
||||
mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
||||
|
||||
notification_id = uuid.uuid4()
|
||||
|
||||
save_email(
|
||||
template.service_id,
|
||||
notification_id,
|
||||
encryption.encrypt(notification),
|
||||
)
|
||||
|
||||
persisted_notification = Notification.query.one()
|
||||
provider_tasks.deliver_email.apply_async.assert_called_once_with(
|
||||
[str(persisted_notification.id)],
|
||||
queue="research-mode-tasks"
|
||||
)
|
||||
|
||||
|
||||
def test_should_save_sms_template_to_and_persist_with_job_id(sample_job, mocker):
|
||||
notification = _notification_json(
|
||||
sample_job.template,
|
||||
|
||||
@@ -4,7 +4,7 @@ from unittest.mock import ANY
|
||||
import pytest
|
||||
from flask import json
|
||||
|
||||
from app.celery.research_mode_tasks import (
|
||||
from app.celery.test_key_tasks import (
|
||||
HTTPError,
|
||||
send_email_response,
|
||||
send_sms_response,
|
||||
@@ -23,7 +23,7 @@ dvla_response_file_matcher = Matcher(
|
||||
|
||||
def test_make_sns_callback(notify_api, rmock, mocker):
|
||||
endpoint = "http://localhost:6011/notifications/sms/sns"
|
||||
get_notification_by_id = mocker.patch('app.celery.research_mode_tasks.get_notification_by_id')
|
||||
get_notification_by_id = mocker.patch('app.celery.test_key_tasks.get_notification_by_id')
|
||||
n = Notification()
|
||||
n.id = 1234
|
||||
n.status = NOTIFICATION_DELIVERED
|
||||
@@ -42,7 +42,7 @@ def test_make_sns_callback(notify_api, rmock, mocker):
|
||||
|
||||
def test_callback_logs_on_api_call_failure(notify_api, rmock, mocker):
|
||||
endpoint = "http://localhost:6011/notifications/sms/sns"
|
||||
get_notification_by_id = mocker.patch('app.celery.research_mode_tasks.get_notification_by_id')
|
||||
get_notification_by_id = mocker.patch('app.celery.test_key_tasks.get_notification_by_id')
|
||||
n = Notification()
|
||||
n.id = 1234
|
||||
n.status = NOTIFICATION_FAILED
|
||||
@@ -66,17 +66,17 @@ def test_callback_logs_on_api_call_failure(notify_api, rmock, mocker):
|
||||
|
||||
|
||||
def test_make_ses_callback(notify_api, mocker):
|
||||
mock_task = mocker.patch('app.celery.research_mode_tasks.process_ses_results')
|
||||
mock_task = mocker.patch('app.celery.test_key_tasks.process_ses_results')
|
||||
some_ref = str(uuid.uuid4())
|
||||
|
||||
send_email_response(reference=some_ref, to="test@test.com")
|
||||
|
||||
mock_task.apply_async.assert_called_once_with(ANY, queue=QueueNames.RESEARCH_MODE)
|
||||
mock_task.apply_async.assert_called_once_with(ANY, queue=QueueNames.SEND_EMAIL)
|
||||
assert mock_task.apply_async.call_args[0][0][0] == ses_notification_callback(some_ref)
|
||||
|
||||
|
||||
def test_delivered_sns_callback(mocker):
|
||||
get_notification_by_id = mocker.patch('app.celery.research_mode_tasks.get_notification_by_id')
|
||||
get_notification_by_id = mocker.patch('app.celery.test_key_tasks.get_notification_by_id')
|
||||
n = Notification()
|
||||
n.id = 1234
|
||||
n.status = NOTIFICATION_DELIVERED
|
||||
Reference in New Issue
Block a user