mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-20 14:29:25 -04:00
@@ -104,10 +104,16 @@ 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=TemplateType.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=TemplateType.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)
|
||||
@@ -352,10 +358,12 @@ 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=TemplateType.EMAIL,
|
||||
service_nothing_to_delete,
|
||||
template_type=TemplateType.EMAIL,
|
||||
)
|
||||
|
||||
# will be deleted as service has no custom retention, but past our default 7 days
|
||||
|
||||
@@ -62,16 +62,20 @@ def test_send_delivery_status_to_service_post_https_request_to_service_with_encr
|
||||
assert request_mock.request_history[0].method == "POST"
|
||||
assert request_mock.request_history[0].text == json.dumps(mock_data)
|
||||
assert request_mock.request_history[0].headers["Content-type"] == "application/json"
|
||||
assert request_mock.request_history[0].headers[
|
||||
"Authorization"
|
||||
] == f"Bearer {callback_api.bearer_token}"
|
||||
assert (
|
||||
request_mock.request_history[0].headers["Authorization"]
|
||||
== 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(NotificationType.EMAIL, CallbackType.COMPLAINT,)
|
||||
callback_api, template = _set_up_test_data(
|
||||
NotificationType.EMAIL,
|
||||
CallbackType.COMPLAINT,
|
||||
)
|
||||
|
||||
notification = create_notification(template=template)
|
||||
complaint = create_complaint(
|
||||
@@ -100,9 +104,10 @@ def test_send_complaint_to_service_posts_https_request_to_service_with_encrypted
|
||||
request_mock.request_history[0].headers["Content-type"]
|
||||
== "application/json"
|
||||
)
|
||||
assert request_mock.request_history[0].headers[
|
||||
"Authorization"
|
||||
] == f"Bearer {callback_api.bearer_token}"
|
||||
assert (
|
||||
request_mock.request_history[0].headers["Authorization"]
|
||||
== f"Bearer {callback_api.bearer_token}"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -113,7 +118,10 @@ 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, CallbackType.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 +151,10 @@ 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, CallbackType.DELIVERY_STATUS,)
|
||||
callback_api, template = _set_up_test_data(
|
||||
notification_type,
|
||||
CallbackType.DELIVERY_STATUS,
|
||||
)
|
||||
datestr = datetime(2017, 6, 20)
|
||||
notification = create_notification(
|
||||
template=template,
|
||||
|
||||
@@ -310,9 +310,7 @@ 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(
|
||||
f"app.celery.tasks.{expected_function}.apply_async"
|
||||
)
|
||||
task_mock = mocker.patch(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)
|
||||
job = Mock(id="job_id", template_version="temp_vers")
|
||||
@@ -1039,9 +1037,10 @@ def test_send_inbound_sms_to_service_post_https_request_to_service(
|
||||
assert request_mock.request_history[0].method == "POST"
|
||||
assert request_mock.request_history[0].text == json.dumps(data)
|
||||
assert request_mock.request_history[0].headers["Content-type"] == "application/json"
|
||||
assert request_mock.request_history[0].headers[
|
||||
"Authorization"
|
||||
] == f"Bearer {inbound_api.bearer_token}"
|
||||
assert (
|
||||
request_mock.request_history[0].headers["Authorization"]
|
||||
== 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