mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
Cleaning up "email" from code.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -104,10 +104,10 @@ def test_will_remove_csv_files_for_jobs_older_than_retention_period(
|
||||
days_of_retention=30,
|
||||
)
|
||||
sms_template_service_1 = create_template(service=service_1)
|
||||
email_template_service_1 = create_template(service=service_1, template_type="email")
|
||||
email_template_service_1 = create_template(service=service_1, template_type=TemplateType.EMAIL,)
|
||||
|
||||
sms_template_service_2 = create_template(service=service_2)
|
||||
email_template_service_2 = create_template(service=service_2, template_type="email")
|
||||
email_template_service_2 = create_template(service=service_2, template_type=TemplateType.EMAIL,)
|
||||
|
||||
four_days_ago = datetime.utcnow() - timedelta(days=4)
|
||||
eight_days_ago = datetime.utcnow() - timedelta(days=8)
|
||||
@@ -153,7 +153,7 @@ def test_delete_email_notifications_older_than_retentions_calls_child_task(
|
||||
"app.celery.nightly_tasks._delete_notifications_older_than_retention_by_type"
|
||||
)
|
||||
delete_email_notifications_older_than_retention()
|
||||
mocked_notifications.assert_called_once_with("email")
|
||||
mocked_notifications.assert_called_once_with(NotificationType.EMAIL)
|
||||
|
||||
|
||||
@freeze_time("2021-12-13T10:00")
|
||||
@@ -352,10 +352,10 @@ def test_delete_notifications_task_calls_task_for_services_that_have_sent_notifi
|
||||
create_template(service_will_delete_1)
|
||||
create_template(service_will_delete_2)
|
||||
nothing_to_delete_sms_template = create_template(
|
||||
service_nothing_to_delete, template_type=TemplateType.SMS
|
||||
service_nothing_to_delete, template_type=TemplateType.SMS,
|
||||
)
|
||||
nothing_to_delete_email_template = create_template(
|
||||
service_nothing_to_delete, template_type="email"
|
||||
service_nothing_to_delete, template_type=TemplateType.EMAIL,
|
||||
)
|
||||
|
||||
# will be deleted as service has no custom retention, but past our default 7 days
|
||||
|
||||
@@ -64,14 +64,14 @@ def test_send_delivery_status_to_service_post_https_request_to_service_with_encr
|
||||
assert request_mock.request_history[0].headers["Content-type"] == "application/json"
|
||||
assert request_mock.request_history[0].headers[
|
||||
"Authorization"
|
||||
] == "Bearer {}".format(callback_api.bearer_token)
|
||||
] == f"Bearer {callback_api.bearer_token}"
|
||||
|
||||
|
||||
def test_send_complaint_to_service_posts_https_request_to_service_with_encrypted_data(
|
||||
notify_db_session,
|
||||
):
|
||||
with freeze_time("2001-01-01T12:00:00"):
|
||||
callback_api, template = _set_up_test_data("email", "complaint")
|
||||
callback_api, template = _set_up_test_data(NotificationType.EMAIL, CallbackType.COMPLAINT,)
|
||||
|
||||
notification = create_notification(template=template)
|
||||
complaint = create_complaint(
|
||||
@@ -102,7 +102,7 @@ def test_send_complaint_to_service_posts_https_request_to_service_with_encrypted
|
||||
)
|
||||
assert request_mock.request_history[0].headers[
|
||||
"Authorization"
|
||||
] == "Bearer {}".format(callback_api.bearer_token)
|
||||
] == f"Bearer {callback_api.bearer_token}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -113,7 +113,7 @@ def test_send_complaint_to_service_posts_https_request_to_service_with_encrypted
|
||||
def test__send_data_to_service_callback_api_retries_if_request_returns_error_code_with_encrypted_data(
|
||||
notify_db_session, mocker, notification_type, status_code
|
||||
):
|
||||
callback_api, template = _set_up_test_data(notification_type, "delivery_status")
|
||||
callback_api, template = _set_up_test_data(notification_type, CallbackType.DELIVERY_STATUS,)
|
||||
datestr = datetime(2017, 6, 20)
|
||||
notification = create_notification(
|
||||
template=template,
|
||||
@@ -143,7 +143,7 @@ def test__send_data_to_service_callback_api_retries_if_request_returns_error_cod
|
||||
def test__send_data_to_service_callback_api_does_not_retry_if_request_returns_404_with_encrypted_data(
|
||||
notify_db_session, mocker, notification_type
|
||||
):
|
||||
callback_api, template = _set_up_test_data(notification_type, "delivery_status")
|
||||
callback_api, template = _set_up_test_data(notification_type, CallbackType.DELIVERY_STATUS,)
|
||||
datestr = datetime(2017, 6, 20)
|
||||
notification = create_notification(
|
||||
template=template,
|
||||
@@ -178,7 +178,7 @@ def test_send_delivery_status_to_service_succeeds_if_sent_at_is_none(
|
||||
created_at=datestr,
|
||||
updated_at=datestr,
|
||||
sent_at=None,
|
||||
status="technical-failure",
|
||||
status=NotificationStatus.TECHNICAL_FAILURE,
|
||||
)
|
||||
encrypted_data = _set_up_data_for_status_update(callback_api, notification)
|
||||
mocked = mocker.patch(
|
||||
|
||||
@@ -116,7 +116,7 @@ def test_should_process_sms_job(sample_job, mocker):
|
||||
queue="database-tasks",
|
||||
)
|
||||
job = jobs_dao.dao_get_job_by_id(sample_job.id)
|
||||
assert job.job_status == "finished"
|
||||
assert job.job_status == JobStatus.FINISHED
|
||||
|
||||
|
||||
def test_should_process_sms_job_with_sender_id(sample_job, mocker, fake_uuid):
|
||||
@@ -138,7 +138,7 @@ def test_should_process_sms_job_with_sender_id(sample_job, mocker, fake_uuid):
|
||||
|
||||
|
||||
def test_should_not_process_job_if_already_pending(sample_template, mocker):
|
||||
job = create_job(template=sample_template, job_status="scheduled")
|
||||
job = create_job(template=sample_template, job_status=JobStatus.SCHEDULED)
|
||||
|
||||
mocker.patch("app.celery.tasks.s3.get_job_and_metadata_from_s3")
|
||||
mocker.patch("app.celery.tasks.process_row")
|
||||
@@ -153,7 +153,7 @@ def test_should_process_job_if_send_limits_are_not_exceeded(
|
||||
notify_api, notify_db_session, mocker
|
||||
):
|
||||
service = create_service(message_limit=10)
|
||||
template = create_template(service=service, template_type="email")
|
||||
template = create_template(service=service, template_type=TemplateType.EMAIL)
|
||||
job = create_job(template=template, notification_count=10)
|
||||
|
||||
mocker.patch(
|
||||
@@ -169,7 +169,7 @@ def test_should_process_job_if_send_limits_are_not_exceeded(
|
||||
service_id=str(job.service.id), job_id=str(job.id)
|
||||
)
|
||||
job = jobs_dao.dao_get_job_by_id(job.id)
|
||||
assert job.job_status == "finished"
|
||||
assert job.job_status == JobStatus.FINISHED
|
||||
tasks.save_email.apply_async.assert_called_with(
|
||||
(
|
||||
str(job.service_id),
|
||||
@@ -238,7 +238,7 @@ def test_should_process_email_job(email_job_with_placeholders, mocker):
|
||||
queue="database-tasks",
|
||||
)
|
||||
job = jobs_dao.dao_get_job_by_id(email_job_with_placeholders.id)
|
||||
assert job.job_status == "finished"
|
||||
assert job.job_status == JobStatus.FINISHED
|
||||
|
||||
|
||||
def test_should_process_email_job_with_sender_id(
|
||||
@@ -293,7 +293,7 @@ def test_should_process_all_sms_job(sample_job_with_placeholdered_template, mock
|
||||
}
|
||||
assert tasks.save_sms.apply_async.call_count == 10
|
||||
job = jobs_dao.dao_get_job_by_id(sample_job_with_placeholdered_template.id)
|
||||
assert job.job_status == "finished"
|
||||
assert job.job_status == JobStatus.FINISHED
|
||||
|
||||
|
||||
# -------------- process_row tests -------------- #
|
||||
@@ -311,7 +311,7 @@ def test_process_row_sends_letter_task(
|
||||
):
|
||||
mocker.patch("app.celery.tasks.create_uuid", return_value="noti_uuid")
|
||||
task_mock = mocker.patch(
|
||||
"app.celery.tasks.{}.apply_async".format(expected_function)
|
||||
f"app.celery.tasks.{expected_function}.apply_async"
|
||||
)
|
||||
encrypt_mock = mocker.patch("app.celery.tasks.encryption.encrypt")
|
||||
template = Mock(id="template_id", template_type=template_type)
|
||||
@@ -1041,7 +1041,7 @@ def test_send_inbound_sms_to_service_post_https_request_to_service(
|
||||
assert request_mock.request_history[0].headers["Content-type"] == "application/json"
|
||||
assert request_mock.request_history[0].headers[
|
||||
"Authorization"
|
||||
] == "Bearer {}".format(inbound_api.bearer_token)
|
||||
] == f"Bearer {inbound_api.bearer_token}"
|
||||
|
||||
|
||||
def test_send_inbound_sms_to_service_does_not_send_request_when_inbound_sms_does_not_exist(
|
||||
|
||||
Reference in New Issue
Block a user