Merge pull request #3161 from alphagov/check-use_numeric_sender

Check international rules to decide on a sender
This commit is contained in:
Rebecca Law
2021-02-25 09:36:29 +00:00
committed by GitHub
4 changed files with 38 additions and 19 deletions

View File

@@ -315,7 +315,7 @@ def test_post_user_attribute_with_updated_by_sends_notification_to_international
):
updater = create_user(name="Service Manago")
update_dict = {
'mobile_number': '601117224412',
'mobile_number': '+601117224412',
'updated_by': str(updater.id)
}
auth_header = create_authorization_header()
@@ -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']