fix tests

This commit is contained in:
Kenneth Kehl
2024-08-20 08:10:14 -07:00
parent 6e22cf101e
commit 7acb10078d
2 changed files with 18 additions and 33 deletions

View File

@@ -82,33 +82,13 @@ def send_sms_to_provider(notification):
# the phone number is for the verification code on login, which is not a job.
recipient = None
# It is our 2facode, maybe
if notification.job_id is None:
key = f"2facode-{notification.id}".replace(" ", "")
recipient = redis_store.get(key)
if recipient:
recipient = recipient.decode("utf-8")
else:
try:
recipient = get_phone_number_from_s3(
notification.service_id,
notification.job_id,
notification.job_row_number,
)
except Exception:
# It is our 2facode, maybe
key = f"2facode-{notification.id}".replace(" ", "")
recipient = redis_store.get(key)
if recipient:
recipient = recipient.decode("utf-8")
recipient = _get_verify_code(notification)
if recipient is None:
si = notification.service_id
ji = notification.job_id
jrn = notification.job_row_number
raise Exception(
f"The recipient for (Service ID: {si}; Job ID: {ji}; Job Row Number {jrn} was not found."
recipient = get_phone_number_from_s3(
notification.service_id,
notification.job_id,
notification.job_row_number,
)
sender_numbers = get_sender_numbers(notification)
@@ -146,6 +126,14 @@ def send_sms_to_provider(notification):
return message_id
def _get_verify_code(notification):
key = f"2facode-{notification.id}".replace(" ", "")
recipient = redis_store.get(key)
if recipient:
recipient = recipient.decode("utf-8")
return recipient
def get_sender_numbers(notification):
possible_senders = dao_get_sms_senders_by_service_id(notification.service_id)
sender_numbers = []