Renamed some tests.

Fix some imports.
Added test for a function
This commit is contained in:
Rebecca Law
2017-11-01 11:01:20 +00:00
parent d671adc1eb
commit 830619194e
5 changed files with 86 additions and 39 deletions

View File

@@ -311,9 +311,9 @@ def test_should_not_rate_limit_if_limiting_is_disabled(
@pytest.mark.parametrize('key_type', ['test', 'normal'])
def test_rejects_api_calls_with_international_numbers_if_service_does_not_allow_int_sms(
key_type,
notify_db,
notify_db_session,
key_type,
notify_db,
notify_db_session,
):
service = create_service(notify_db, notify_db_session, permissions=[SMS_TYPE])
with pytest.raises(BadRequestError) as e:
@@ -336,12 +336,17 @@ def test_check_service_email_reply_to_id_where_reply_to_id_is_none(notification_
assert check_service_email_reply_to_id(None, None, notification_type) is None
def test_check_service_email_reply_to_where_email_reply_to_is_found(sample_service):
reply_to_address = create_reply_to_email(sample_service, "test@test.com")
assert check_service_email_reply_to_id(sample_service.id, reply_to_address.id, EMAIL_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, EMAIL_TYPE)
assert e.value.status_code == 400
assert e.value.message == 'email_reply_to_id {} does not exist in database for service id {}'\
assert e.value.message == 'email_reply_to_id {} does not exist in database for service id {}' \
.format(reply_to_address.id, fake_uuid)
@@ -349,30 +354,25 @@ def test_check_service_email_reply_to_id_where_reply_to_id_is_not_found(sample_s
with pytest.raises(BadRequestError) as e:
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 {}'\
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_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')
@pytest.mark.parametrize('notification_type', ['sms', 'letter'])
def test_check_service_email_reply_to_id_when_channel_type_is_wrong(sample_service, notification_type):
reply_to_address = create_reply_to_email(sample_service, "test@test.com")
with pytest.raises(BadRequestError) as e:
check_service_sms_sender_id(sample_service.id, sms_sender.id, notification_type)
check_service_email_reply_to_id(sample_service.id, reply_to_address.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)
assert e.value.message == 'email_reply_to_id is not a valid option for {} notification'.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):
def test_check_service_sms_sender_id_where_sms_sender_id_is_none(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):
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
@@ -382,22 +382,22 @@ def test_check_service_sms_sender_id_where_service_id_is_not_found(sample_servic
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 {}'\
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):
def test_check_service_sms_sender_id_where_sms_sender_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 {}'\
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):
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)
assert e.value.message == 'sms_sender_id is not a valid option for {} notification'.format(notification_type)