From f29c6c90c072520a976f32486ec88a8bb96b46d5 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 20 Sep 2018 10:06:56 +0100 Subject: [PATCH] Add info about checklist to ticket So that someone picking up a ticket can be warned that they should be checking these things. --- app/main/views/service_settings.py | 2 + app/notify_client/models.py | 20 ++++ tests/app/main/views/test_service_settings.py | 112 +++++++++++++++++- 3 files changed, 132 insertions(+), 2 deletions(-) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 98ff57e0b..46d9a7319 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -199,6 +199,7 @@ def submit_request_to_go_live(service_id): '\n---' '\nOrganisation type: {organisation_type}' '\nAgreement signed: {agreement}' + '\nChecklist completed: {checklist}' '\nEmails in next year: {volume_email}' '\nText messages in next year: {volume_sms}' '\nLetters in next year: {volume_letter}' @@ -221,6 +222,7 @@ def submit_request_to_go_live(service_id): service_dashboard=url_for('main.service_dashboard', service_id=current_service.id, _external=True), organisation_type=str(current_service.organisation_type).title(), agreement=AgreementInfo.from_current_user().as_human_readable, + checklist='Yes' if current_service.go_live_checklist_completed else 'No', volume_email=form.volume_email.data, volume_sms=form.volume_sms.data, volume_letter=form.volume_letter.data, diff --git a/app/notify_client/models.py b/app/notify_client/models.py index 6e429f0fa..0a09e29b1 100644 --- a/app/notify_client/models.py +++ b/app/notify_client/models.py @@ -355,3 +355,23 @@ class Service(dict): return get_default_sms_sender( service_api_client.get_sms_senders(self.id) ) in {'GOVUK', 'None'} + + @property + def go_live_checklist_completed(self): + return all(( + self.has_team_members, + self.has_templates, + any(( + not self.has_email_templates, + self.has_email_reply_to_address, + )), + any(( + not self.has_sms_templates, + not self.shouldnt_use_govuk_as_sms_sender, + not self.sms_sender_is_govuk, + )) + )) + + @property + def go_live_checklist_completed_as_yes_no(self): + return 'Yes' if self.go_live_checklist_completed else 'No' diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index f35ca07ce..c3f48ea51 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -1,6 +1,6 @@ import uuid from functools import partial -from unittest.mock import ANY, call +from unittest.mock import ANY, PropertyMock, call from urllib.parse import parse_qs, urlparse import pytest @@ -737,7 +737,9 @@ def test_should_redirect_after_request_to_go_live( single_letter_contact_block, mock_get_service_organisation, single_sms_sender, - mock_get_service_settings_page_common + mock_get_service_settings_page_common, + mock_get_service_templates, + mock_get_users_by_service, ): mock_post = mocker.patch('app.main.views.service_settings.zendesk_client.create_ticket', autospec=True) page = client_request.post( @@ -765,6 +767,7 @@ def test_should_redirect_after_request_to_go_live( '---\n' 'Organisation type: Central\n' 'Agreement signed: Can’t tell (domain is user.gov.uk)\n' + 'Checklist completed: No\n' 'Emails in next year: 111\n' 'Text messages in next year: 222\n' 'Letters in next year: 333\n' @@ -782,6 +785,111 @@ def test_should_redirect_after_request_to_go_live( ) +@pytest.mark.parametrize( + ( + 'has_team_members,' + 'has_templates,' + 'has_email_templates,' + 'has_sms_templates,' + 'has_email_reply_to_address,' + 'shouldnt_use_govuk_as_sms_sender,' + 'sms_sender_is_govuk,' + 'expected,' + ), + ( + ( # Just sending email + True, + True, + True, + False, + True, + True, + True, + 'Yes', + ), + ( # Needs to set reply to address + True, + True, + True, + False, + False, + True, + True, + 'No', + ), + ( # Just sending SMS + True, + True, + False, + True, + True, + True, + False, + 'Yes', + ), + ( # Needs to change SMS sender + True, + True, + False, + True, + True, + True, + True, + 'No', + ), + ( # Needs team members + False, + True, + False, + True, + True, + True, + False, + 'No', + ), + ( # Needs templates + True, + False, + False, + True, + True, + True, + False, + 'No', + ), + ), +) +def test_ready_to_go_live( + client_request, + mocker, + has_team_members, + has_templates, + has_email_templates, + has_sms_templates, + has_email_reply_to_address, + shouldnt_use_govuk_as_sms_sender, + sms_sender_is_govuk, + expected, +): + for prop in { + 'has_team_members', + 'has_templates', + 'has_email_templates', + 'has_sms_templates', + 'has_email_reply_to_address', + 'shouldnt_use_govuk_as_sms_sender', + 'sms_sender_is_govuk', + }: + mocker.patch( + 'app.notify_client.models.Service.{}'.format(prop), + new_callable=PropertyMock + ).return_value = locals()[prop] + + assert app.notify_client.models.Service({ + 'id': fake_uuid() + }).go_live_checklist_completed_as_yes_no == expected + + @pytest.mark.parametrize('route', [ 'main.service_settings', 'main.service_name_change',