From 83bfc5088427d6dbb6ed68ab1ff8c84c8caab30c Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Thu, 2 Nov 2017 14:58:14 +0000 Subject: [PATCH] Added a hint for Receives replies --- app/main/views/send.py | 6 +++++- app/notify_client/notification_api_client.py | 1 - tests/app/main/views/test_send.py | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index 63863f0f7..0db544410 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -192,7 +192,8 @@ def set_sender(service_id, template_id): sender_choices=sender_context['value_and_label'], sender_label=sender_context['description'] ) - option_hints = {sender_context['default_id']: 'Default'} + option_hints = {sender_context['default_id']: 'Default', + sender_context['receives_text_message']: 'Receives replies'} if form.validate_on_submit(): session['sender_id'] = form.sender.data @@ -231,6 +232,9 @@ def get_sender_context(sender_details, template_type): sender_format = context['field_name'] context['default_id'] = next(sender['id'] for sender in sender_details if sender['is_default']) + if template_type == 'sms': + context['receives_text_message'] = next( + sender['id'] for sender in sender_details if sender['inbound_number_id']) context['value_and_label'] = [(sender['id'], sender[sender_format]) for sender in sender_details] return context diff --git a/app/notify_client/notification_api_client.py b/app/notify_client/notification_api_client.py index d9ce5a8d8..195d089ac 100644 --- a/app/notify_client/notification_api_client.py +++ b/app/notify_client/notification_api_client.py @@ -61,7 +61,6 @@ class NotificationApiClient(NotifyAdminAPIClient): 'personalisation': personalisation, } if sender_id: - print(sender_id) data['sender_id'] = sender_id data = _attach_current_user(data) return self.post(url='/service/{}/send-notification'.format(service_id), data=data) diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 2880743a4..55128afaa 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -107,6 +107,25 @@ def test_default_sender_is_checked_and_has_hint( assert not page.select('.multiple-choice input')[2].has_attr('checked') +def test_sms_sender_is_has_receives_replies_hint( + client_request, + service_one, + fake_uuid, + mock_get_service_template, + multiple_sms_senders +): + page = client_request.get( + '.set_sender', + service_id=service_one['id'], + template_id=fake_uuid + ) + + assert page.select('.multiple-choice input')[0].has_attr('checked') + assert normalize_spaces(page.select_one('.multiple-choice label .block-label-hint').text) == "Receives replies" + assert not page.select('.multiple-choice input')[1].has_attr('checked') + assert not page.select('.multiple-choice input')[2].has_attr('checked') + + @pytest.mark.parametrize('template_mock, sender_data', [ ( mock_get_service_email_template,