add other send notification error branches and tests

This commit is contained in:
Leo Hemsted
2017-06-29 16:06:36 +01:00
parent 42e33ce9e6
commit 87aeec1b8d
6 changed files with 56 additions and 11 deletions

View File

@@ -51,6 +51,8 @@ class Config(object):
SESSION_COOKIE_SECURE = True
SESSION_REFRESH_EACH_REQUEST = True
SHOW_STYLEGUIDE = True
# TODO: move to utils
SMS_CHAR_COUNT_LIMIT = 459
TOKEN_MAX_AGE_SECONDS = 3600
WTF_CSRF_ENABLED = True
WTF_CSRF_TIME_LIMIT = None

View File

@@ -638,14 +638,23 @@ def _check_notification(service_id, template_id, exception=None):
def get_template_error_dict(exception):
# TODO: Make API return some computer-friendly identifier as well as the end user error messages
if 'service is in trial mode' in exception.message:
error = 'not-allowed-to-send-to'
elif 'Exceeded send limits' in exception.message:
error = 'too-many-messages'
elif 'Content for template has a character count greater than the limit of' in exception.message:
error = 'message-too-long'
else:
raise exception
return {
'error': error,
'SMS_CHAR_COUNT_LIMIT': 0
'SMS_CHAR_COUNT_LIMIT': current_app.config['SMS_CHAR_COUNT_LIMIT'],
'current_service': current_service,
# used to trigger CSV specific err msg content, so not needed for single notification errors.
'original_file_name': False
}
@@ -668,6 +677,10 @@ def send_notification(service_id, template_id):
personalisation=session['placeholders']
)
except HTTPError as exception:
current_app.logger.info('Service {} could not send notification: "{}"'.format(
current_service['id'],
exception.message
))
return _check_notification(service_id, template_id, exception)
session.pop('placeholders')

View File

@@ -1,3 +1,5 @@
{% from "components/banner.html" import banner_wrapper %}
<div class="bottom-gutter">
{% call banner_wrapper(type='dangerous') %}
<h1 class='banner-title'>

View File

@@ -1,3 +1,5 @@
{% from "components/banner.html" import banner_wrapper %}
<div class="bottom-gutter">
{% call banner_wrapper(type='dangerous') %}
<h1 class='banner-title'>

View File

@@ -14,9 +14,9 @@
%}
{% include "partials/check/not-allowed-to-send-to.html" %}
{% endwith %}
{% elif error == 'more_rows_than_can_send' %}
{% elif error == 'too-many-messages' %}
{% include "partials/check/too-many-messages.html" %}
{% elif error == 'row_errors' %}
{% elif error == 'message-too-long' %}
{# the only row_errors we can get when sending one off messages is that the message is too long #}
{% include "partials/check/message-too-long.html" %}
{% else %}