More cleanup.

Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
Cliff Hill
2024-02-09 13:46:44 -05:00
parent 9cc3f1c1ff
commit 262bd8943a
3 changed files with 129 additions and 128 deletions

View File

@@ -10,6 +10,7 @@ from app.celery.service_callback_tasks import (
send_complaint_to_service,
send_delivery_status_to_service,
)
from app.enums import CallbackType, NotificationStatus, NotificationType
from app.utils import DATETIME_FORMAT
from tests.app.db import (
create_complaint,
@@ -20,7 +21,7 @@ from tests.app.db import (
)
@pytest.mark.parametrize("notification_type", ["email", "sms"])
@pytest.mark.parametrize("notification_type", [NotificationType.EMAIL, NotificationType.SMS])
def test_send_delivery_status_to_service_post_https_request_to_service_with_encrypted_data(
notify_db_session, notification_type
):
@@ -32,7 +33,7 @@ def test_send_delivery_status_to_service_post_https_request_to_service_with_encr
created_at=datestr,
updated_at=datestr,
sent_at=datestr,
status="sent",
status=NotificationStatus.SENT,
)
encrypted_status_update = _set_up_data_for_status_update(callback_api, notification)
with requests_mock.Mocker() as request_mock:
@@ -102,7 +103,7 @@ def test_send_complaint_to_service_posts_https_request_to_service_with_encrypted
] == "Bearer {}".format(callback_api.bearer_token)
@pytest.mark.parametrize("notification_type", ["email", "sms"])
@pytest.mark.parametrize("notification_type", [NotificationType.EMAIL, NotificationType.SMS],)
@pytest.mark.parametrize("status_code", [429, 500, 503])
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
@@ -114,7 +115,7 @@ def test__send_data_to_service_callback_api_retries_if_request_returns_error_cod
created_at=datestr,
updated_at=datestr,
sent_at=datestr,
status="sent",
status=NotificationStatus.SENT,
)
encrypted_data = _set_up_data_for_status_update(callback_api, notification)
mocked = mocker.patch(
@@ -130,7 +131,7 @@ def test__send_data_to_service_callback_api_retries_if_request_returns_error_cod
assert mocked.call_args[1]["queue"] == "service-callbacks-retry"
@pytest.mark.parametrize("notification_type", ["email", "sms"])
@pytest.mark.parametrize("notification_type", [NotificationType.EMAIL, NotificationType.SMS],)
def test__send_data_to_service_callback_api_does_not_retry_if_request_returns_404_with_encrypted_data(
notify_db_session, mocker, notification_type
):
@@ -159,7 +160,7 @@ def test__send_data_to_service_callback_api_does_not_retry_if_request_returns_40
def test_send_delivery_status_to_service_succeeds_if_sent_at_is_none(
notify_db_session, mocker
):
callback_api, template = _set_up_test_data("email", "delivery_status")
callback_api, template = _set_up_test_data(NotificationType.EMAIL, CallbackType.DELIVERY_STATUS,)
datestr = datetime(2017, 6, 20)
notification = create_notification(
template=template,