mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
Added an optional parameter in the form for POST /v2/notifications/sms and /service/<service_id>/send-notification to pass in the SMS sender id.
The send_sms_to_provider still needs to use the SMS sender being passed in to the POST. As part of https://www.pivotaltracker.com/story/show/152106587
This commit is contained in:
@@ -11,8 +11,8 @@ from app.notifications.validators import (
|
||||
check_sms_content_char_count,
|
||||
check_service_over_api_rate_limit,
|
||||
validate_and_format_recipient,
|
||||
check_service_email_reply_to_id
|
||||
)
|
||||
check_service_email_reply_to_id,
|
||||
check_service_sms_sender_id)
|
||||
|
||||
from app.v2.errors import (
|
||||
BadRequestError,
|
||||
@@ -23,7 +23,7 @@ from tests.app.conftest import (
|
||||
sample_service as create_service,
|
||||
sample_service_whitelist,
|
||||
sample_api_key)
|
||||
from tests.app.db import create_reply_to_email
|
||||
from tests.app.db import create_reply_to_email, create_service_sms_sender
|
||||
|
||||
|
||||
@pytest.mark.parametrize('key_type', ['test', 'team', 'normal'])
|
||||
@@ -331,14 +331,15 @@ def test_allows_api_calls_with_international_numbers_if_service_does_allow_int_s
|
||||
assert result == '201212341234'
|
||||
|
||||
|
||||
def test_check_service_email_reply_to_id_where_reply_to_id_is_none():
|
||||
assert check_service_email_reply_to_id(None, None) is None
|
||||
@pytest.mark.parametrize('notification_type', ['sms', 'email', 'letter'])
|
||||
def test_check_service_email_reply_to_id_where_reply_to_id_is_none(notification_type):
|
||||
assert check_service_email_reply_to_id(None, None, notification_type) is None
|
||||
|
||||
|
||||
def test_check_service_email_reply_to_id_where_service_id_is_not_found(sample_service, fake_uuid):
|
||||
reply_to_address = create_reply_to_email(sample_service, "test@test.com")
|
||||
with pytest.raises(BadRequestError) as e:
|
||||
check_service_email_reply_to_id(fake_uuid, reply_to_address.id)
|
||||
check_service_email_reply_to_id(fake_uuid, reply_to_address.id, EMAIL_TYPE)
|
||||
assert e.value.status_code == 400
|
||||
assert e.value.message == 'email_reply_to_id {} does not exist in database for service id {}'\
|
||||
.format(reply_to_address.id, fake_uuid)
|
||||
@@ -346,12 +347,57 @@ def test_check_service_email_reply_to_id_where_service_id_is_not_found(sample_se
|
||||
|
||||
def test_check_service_email_reply_to_id_where_reply_to_id_is_not_found(sample_service, fake_uuid):
|
||||
with pytest.raises(BadRequestError) as e:
|
||||
check_service_email_reply_to_id(sample_service.id, fake_uuid)
|
||||
check_service_email_reply_to_id(sample_service.id, fake_uuid, EMAIL_TYPE)
|
||||
assert e.value.status_code == 400
|
||||
assert e.value.message == 'email_reply_to_id {} does not exist in database for service id {}'\
|
||||
.format(fake_uuid, sample_service.id)
|
||||
|
||||
|
||||
def test_check_service_email_reply_to_id_where_reply_to_id_is_found(sample_service):
|
||||
reply_to_email = create_reply_to_email(sample_service, 'test@test.com')
|
||||
assert check_service_email_reply_to_id(sample_service.id, reply_to_email.id) is None
|
||||
def test_check_service_sms_sender_id_where_sms_sender_id_is_found(sample_service):
|
||||
sms_sender = create_service_sms_sender(service=sample_service, sms_sender='123456')
|
||||
assert check_service_sms_sender_id(sample_service.id, sms_sender.id, SMS_TYPE) is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize('notification_type', ['email', 'letter'])
|
||||
def test_check_service_sms_sender_id_when_channel_type_is_wrong(sample_service, notification_type):
|
||||
sms_sender = create_service_sms_sender(service=sample_service, sms_sender='123456')
|
||||
with pytest.raises(BadRequestError) as e:
|
||||
check_service_sms_sender_id(sample_service.id, sms_sender.id, notification_type)
|
||||
assert e.value.status_code == 400
|
||||
assert e.value.message == 'You sent a sms_sender_id for a {} notification type'.format(notification_type)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('notification_type', ['sms', 'email', 'letter'])
|
||||
def test_check_service_sms_sender_id_where_reply_to_id_is_valid(notification_type):
|
||||
assert check_service_sms_sender_id(None, None, notification_type) is None
|
||||
|
||||
|
||||
def test_check_service_sms_sender_id_where_reply_to_id_is_found(sample_service):
|
||||
sms_sender = create_service_sms_sender(service=sample_service, sms_sender='123456')
|
||||
assert check_service_sms_sender_id(sample_service.id, sms_sender.id, SMS_TYPE) is None
|
||||
|
||||
|
||||
def test_check_service_sms_sender_id_where_service_id_is_not_found(sample_service, fake_uuid):
|
||||
sms_sender = create_service_sms_sender(service=sample_service, sms_sender='123456')
|
||||
with pytest.raises(BadRequestError) as e:
|
||||
check_service_sms_sender_id(fake_uuid, sms_sender.id, SMS_TYPE)
|
||||
assert e.value.status_code == 400
|
||||
assert e.value.message == 'sms_sender_id {} does not exist in database for service id {}'\
|
||||
.format(sms_sender.id, fake_uuid)
|
||||
|
||||
|
||||
def test_check_service_sms_sender_id_where_reply_to_id_is_not_found(sample_service, fake_uuid):
|
||||
with pytest.raises(BadRequestError) as e:
|
||||
check_service_sms_sender_id(sample_service.id, fake_uuid, SMS_TYPE)
|
||||
assert e.value.status_code == 400
|
||||
assert e.value.message == 'sms_sender_id {} does not exist in database for service id {}'\
|
||||
.format(fake_uuid, sample_service.id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('notification_type', ['email', 'letter'])
|
||||
def test_check_service_email_reply_to_id_when_channel_type_is_wrong(sample_service, notification_type):
|
||||
sms_sender = create_service_sms_sender(service=sample_service, sms_sender='123456')
|
||||
with pytest.raises(BadRequestError) as e:
|
||||
check_service_sms_sender_id(sample_service.id, sms_sender.id, notification_type)
|
||||
assert e.value.status_code == 400
|
||||
assert e.value.message == 'You sent a sms_sender_id for a {} notification type'.format(notification_type)
|
||||
|
||||
Reference in New Issue
Block a user