mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 18:01:08 -05:00
Rename method for clarity
Added unit test for new method.
This commit is contained in:
@@ -105,7 +105,7 @@ def update_user_attribute(user_id):
|
||||
elif 'mobile_number' in update_dct:
|
||||
template = dao_get_template_by_id(current_app.config['TEAM_MEMBER_EDIT_MOBILE_TEMPLATE_ID'])
|
||||
recipient = user_to_update.mobile_number
|
||||
reply_to = set_reply_to(recipient, template)
|
||||
reply_to = get_sms_reply_to_for_notify_service(recipient, template)
|
||||
else:
|
||||
return jsonify(data=user_to_update.serialize()), 200
|
||||
service = Service.query.get(current_app.config['NOTIFY_SERVICE_ID'])
|
||||
@@ -130,7 +130,7 @@ def update_user_attribute(user_id):
|
||||
return jsonify(data=user_to_update.serialize()), 200
|
||||
|
||||
|
||||
def set_reply_to(recipient, template):
|
||||
def get_sms_reply_to_for_notify_service(recipient, template):
|
||||
if not is_uk_phone_number(recipient) and use_numeric_sender(recipient):
|
||||
reply_to = current_app.config['NOTIFY_INTERNATIONAL_SMS_SENDER']
|
||||
else:
|
||||
@@ -276,7 +276,7 @@ def create_2fa_code(template_id, user_to_send_to, secret_code, recipient, person
|
||||
create_user_code(user_to_send_to, secret_code, template.template_type)
|
||||
reply_to = None
|
||||
if template.template_type == SMS_TYPE:
|
||||
reply_to = set_reply_to(recipient, template)
|
||||
reply_to = get_sms_reply_to_for_notify_service(recipient, template)
|
||||
elif template.template_type == EMAIL_TYPE:
|
||||
reply_to = template.service.get_default_reply_to_email_address()
|
||||
saved_notification = persist_notification(
|
||||
|
||||
@@ -1086,3 +1086,20 @@ def test_search_for_users_by_email_handles_incorrect_data_format(notify_db, clie
|
||||
|
||||
assert response.status_code == 400
|
||||
assert json.loads(response.get_data(as_text=True))['message'] == {'email': ['Not a valid string.']}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('number, expected_reply_to',
|
||||
[
|
||||
("1-403-123-4567", "notify_international_sender"),
|
||||
("27 123 4569 2312", "notify_international_sender"),
|
||||
("30 123 4567 7890", "Notify"),
|
||||
("+20 123 4567 7890", "Notify"),
|
||||
])
|
||||
def test_get_sms_reply_to_for_notify_service(team_member_mobile_edit_template, number, expected_reply_to):
|
||||
# need to import locally to avoid db session errors,
|
||||
# if this import is with the other imports at the top of the file
|
||||
# the imports happen in the wrong order and you'll see "dummy session" errors
|
||||
from app.user.rest import get_sms_reply_to_for_notify_service
|
||||
reply_to = get_sms_reply_to_for_notify_service(number, team_member_mobile_edit_template)
|
||||
assert reply_to == current_app.config['NOTIFY_INTERNATIONAL_SMS_SENDER'] \
|
||||
if expected_reply_to == 'notify_international_sender' else current_app.config['FROM_NUMBER']
|
||||
|
||||
Reference in New Issue
Block a user