Make one-off error refer to correct message type

This was hard coded to say ‘You can’t send to this phone number’ even
when you were trying to send an email.
This commit is contained in:
Chris Hill-Scott
2017-07-25 23:06:55 +01:00
parent 2291c4faf4
commit a58d881647
2 changed files with 32 additions and 1 deletions

View File

@@ -12,7 +12,9 @@
{% call banner_wrapper(type='dangerous') %}
{% with
count_of_recipients=1,
template_type_label='phone number'
template_type_label=(
'phone number' if template.template_type == 'sms' else 'email address'
)
%}
{% include "partials/check/not-allowed-to-send-to.html" %}
{% endwith %}

View File

@@ -1940,3 +1940,32 @@ def test_send_notification_shows_error_if_400(
assert normalize_spaces(page.select('.banner-dangerous h1')[0].text) == expected_h1
assert normalize_spaces(page.select('.banner-dangerous p')[0].text) == expected_err_details
assert not page.find('input[type=submit]')
def test_send_notification_shows_email_error_in_trial_mode(
client_request,
fake_uuid,
mocker,
mock_get_service_email_template,
):
mocker.patch(
'app.notification_api_client.send_notification',
side_effect=HTTPError(response=Mock(status_code=400), message=TRIAL_MODE_MSG)
)
with client_request.session_transaction() as session:
session['recipient'] = 'test@example.com'
session['placeholders'] = {'date': 'foo', 'thing': 'bar'}
page = client_request.post(
'main.send_notification',
service_id=SERVICE_ONE_ID,
template_id=fake_uuid,
_expected_status=200,
)
assert normalize_spaces(page.select('.banner-dangerous h1')[0].text) == (
'You cant send to this email address'
)
assert normalize_spaces(page.select('.banner-dangerous p')[0].text) == (
'In trial mode you can only send to yourself and members of your team'
)