Merge branch 'master' into caching-with-redis

Conflicts:
	app/celery/tasks.py
	tests/app/celery/test_tasks.py
This commit is contained in:
Martyn Inglis
2016-11-21 13:10:22 +00:00
42 changed files with 1417 additions and 936 deletions

View File

@@ -24,6 +24,7 @@ from tests.app.conftest import (
def test_exception_thown_by_redis_store_get_should_not_be_fatal(
notify_db,
notify_db_session,
notify_api,
key_type,
mocker):
mocker.patch('app.notifications.validators.redis_store.redis_store.get', side_effect=Exception("broken redis"))
@@ -36,7 +37,6 @@ def test_exception_thown_by_redis_store_get_should_not_be_fatal(
with pytest.raises(TooManyRequestsError) as e:
check_service_message_limit(key_type, service)
assert e.value.status_code == 429
assert e.value.code == '10429'
assert e.value.message == 'Exceeded send limits (4) for today'
assert e.value.fields == []
app.notifications.validators.redis_store.set.assert_not_called()
@@ -115,7 +115,6 @@ def test_check_service_message_limit_over_message_limit_fails(key_type, notify_d
with pytest.raises(TooManyRequestsError) as e:
check_service_message_limit(key_type, service)
assert e.value.status_code == 429
assert e.value.code == '10429'
assert e.value.message == 'Exceeded send limits (4) for today'
assert e.value.fields == []
app.notifications.validators.redis_store.set.assert_called_with(
@@ -138,7 +137,6 @@ def test_check_service_message_limit_in_cache_over_message_limit_fails(
with pytest.raises(TooManyRequestsError) as e:
check_service_message_limit(key_type, service)
assert e.value.status_code == 429
assert e.value.code == '10429'
assert e.value.message == 'Exceeded send limits (4) for today'
assert e.value.fields == []
app.notifications.validators.redis_store.set.assert_not_called()
@@ -161,10 +159,9 @@ def test_check_template_is_for_notification_type_fails_when_template_type_does_n
with pytest.raises(BadRequestError) as e:
check_template_is_for_notification_type(notification_type=notification_type,
template_type=template_type)
assert e.value.code == 10400
assert e.value.status_code == 400
error_message = '{0} template is not suitable for {1} notification'.format(template_type, notification_type)
assert e.value.message == error_message
assert e.value.link == 'link to documentation'
assert e.value.fields == [{'template': error_message}]
@@ -179,9 +176,7 @@ def test_check_template_is_active_fails(sample_template):
with pytest.raises(BadRequestError) as e:
check_template_is_active(sample_template)
assert e.value.status_code == 400
assert e.value.code == 10400
assert e.value.message == 'Template has been deleted'
assert e.value.link == "link to documentation"
assert e.value.fields == [{'template': 'Template has been deleted'}]
@@ -234,9 +229,7 @@ def test_service_can_send_to_recipient_fails_when_recipient_is_not_on_team(recip
key_type,
trial_mode_service)
assert exec_info.value.status_code == 400
assert exec_info.value.code == 10400
assert exec_info.value.message == error_message
assert exec_info.value.link == 'link to documentation'
assert exec_info.value.fields == []
@@ -247,9 +240,7 @@ def test_service_can_send_to_recipient_fails_when_mobile_number_is_not_on_team(n
'team',
live_service)
assert e.value.status_code == 400
assert e.value.code == 10400
assert e.value.message == 'Cant send to this recipient using a team-only API key'
assert e.value.link == 'link to documentation'
assert e.value.fields == []
@@ -263,8 +254,6 @@ def test_check_sms_content_char_count_fails(char_count, notify_api):
with pytest.raises(BadRequestError) as e:
check_sms_content_char_count(char_count)
assert e.value.status_code == 400
assert e.value.code == 10400
assert e.value.message == 'Content for template has a character count greater than the limit of {}'.format(
notify_api.config['SMS_CHAR_COUNT_LIMIT'])
assert e.value.link == 'link to documentation'
assert e.value.fields == []