mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-21 07:51:13 -05:00
@@ -87,9 +87,7 @@ def persist_notification(
|
|||||||
if not notification_id:
|
if not notification_id:
|
||||||
notification_id = uuid.uuid4()
|
notification_id = uuid.uuid4()
|
||||||
|
|
||||||
current_app.logger.info(
|
current_app.logger.info(f"Persisting notification with id {notification_id}")
|
||||||
"Persisting notification with id {}".format(notification_id)
|
|
||||||
)
|
|
||||||
|
|
||||||
notification = Notification(
|
notification = Notification(
|
||||||
id=notification_id,
|
id=notification_id,
|
||||||
@@ -124,9 +122,7 @@ def persist_notification(
|
|||||||
notification.phone_prefix = recipient_info.country_prefix
|
notification.phone_prefix = recipient_info.country_prefix
|
||||||
notification.rate_multiplier = recipient_info.billable_units
|
notification.rate_multiplier = recipient_info.billable_units
|
||||||
elif notification_type == EMAIL_TYPE:
|
elif notification_type == EMAIL_TYPE:
|
||||||
current_app.logger.info(
|
current_app.logger.info(f"Persisting notification with type: {EMAIL_TYPE}")
|
||||||
"Persisting notification with type: {}".format(EMAIL_TYPE)
|
|
||||||
)
|
|
||||||
notification.normalised_to = format_email_address(notification.to)
|
notification.normalised_to = format_email_address(notification.to)
|
||||||
|
|
||||||
# if simulated create a Notification model to return but do not persist the Notification to the dB
|
# if simulated create a Notification model to return but do not persist the Notification to the dB
|
||||||
@@ -141,9 +137,7 @@ def persist_notification(
|
|||||||
)
|
)
|
||||||
|
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
"{} {} created at {}".format(
|
f"{notification_type} {notification_id} created at {notification_created_at}"
|
||||||
notification_type, notification_id, notification_created_at
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return notification
|
return notification
|
||||||
|
|
||||||
@@ -170,15 +164,13 @@ def send_notification_to_queue_detached(
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
current_app.logger.debug(
|
current_app.logger.debug(
|
||||||
"{} {} sent to the {} queue for delivery".format(
|
f"{notification_type} {notification_id} sent to the {queue} queue for delivery"
|
||||||
notification_type, notification_id, queue
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def send_notification_to_queue(notification, queue=None):
|
def send_notification_to_queue(notification, queue=None):
|
||||||
send_notification_to_queue_detached(
|
send_notification_to_queue_detached(
|
||||||
notification.key_type, notification.notification_type, notification.id, queue
|
notification.key_type, notification.notification_type, notification.id, queue,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from functools import partial
|
||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@@ -202,9 +203,12 @@ def test_get_invited_user_by_service_when_user_does_not_belong_to_the_service(
|
|||||||
assert json_resp["result"] == "error"
|
assert json_resp["result"] == "error"
|
||||||
|
|
||||||
|
|
||||||
def test_resend_expired_invite(client, sample_expired_user):
|
def test_resend_expired_invite(client, sample_expired_user, mocker):
|
||||||
url = f"/service/{sample_expired_user.service_id}/invite/{sample_expired_user.id}"
|
url = f"/service/{sample_expired_user.service_id}/invite/{sample_expired_user.id}"
|
||||||
# TODO: Don't actually send email, need to mock it out.
|
mock_send = mocker.patch("app.service_invite.rest.send_notification_to_queue")
|
||||||
|
mock_persist = mocker.patch("app.service_invite.rest.persist_notification")
|
||||||
|
from app.notifications.process_notifications import persist_notification
|
||||||
|
mock_persist.side_effect = partial(persist_notification, simulated=True)
|
||||||
auth_header = create_admin_authorization_header()
|
auth_header = create_admin_authorization_header()
|
||||||
response = client.post(
|
response = client.post(
|
||||||
url,
|
url,
|
||||||
|
|||||||
Reference in New Issue
Block a user