From c6447c111d80994a44303dca1fcbc2ef14a6c204 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 12 Apr 2019 15:35:51 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20let=20admin=20specify=20brandin?= =?UTF-8?q?g=20for=20new=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It doesn’t need to because the API code works it all out now by looking at the organisation. --- app/dao/services_dao.py | 9 ++------- tests/app/dao/test_services_dao.py | 21 +-------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/app/dao/services_dao.py b/app/dao/services_dao.py index 8994d92ff..8153606a4 100644 --- a/app/dao/services_dao.py +++ b/app/dao/services_dao.py @@ -168,7 +168,6 @@ def dao_create_service( user, service_id=None, service_permissions=None, - letter_branding=None, ): # the default property does not appear to work when there is a difference between the sqlalchemy schema and the # db schema (ie: during a migration), so we have to set sms_sender manually here. After the GOVUK sms_sender @@ -198,9 +197,6 @@ def dao_create_service( # do we just add the default - or will we get a value from FE? insert_service_sms_sender(service, current_app.config['FROM_NUMBER']) - if letter_branding: - service.letter_branding = letter_branding - if organisation: service.organisation = organisation @@ -211,9 +207,8 @@ def dao_create_service( if organisation.letter_branding and not service.letter_branding: service.letter_branding = organisation.letter_branding - if not organisation and ( - service.organisation_type == 'nhs' or email_address_is_nhs(user.email_address) - ): + elif service.organisation_type == 'nhs' or email_address_is_nhs(user.email_address): + service.email_branding = dao_get_email_branding_by_name('NHS') service.letter_branding = dao_get_letter_branding_by_name('NHS') diff --git a/tests/app/dao/test_services_dao.py b/tests/app/dao/test_services_dao.py index 4a79d1b20..c04975e35 100644 --- a/tests/app/dao/test_services_dao.py +++ b/tests/app/dao/test_services_dao.py @@ -102,25 +102,6 @@ def test_create_service(notify_db_session): assert not service.letter_branding -def test_create_service_with_letter_branding(notify_db_session): - user = create_user() - create_letter_branding() - letter_branding = create_letter_branding( - name='test domain', filename='test-domain', - ) - assert Service.query.count() == 0 - service = Service(name="service_name", - email_from="email_from", - message_limit=1000, - restricted=False, - organisation_type='central', - created_by=user) - dao_create_service(service, user, letter_branding=letter_branding) - service_db = Service.query.one() - assert service_db.id == service.id - assert service.letter_branding == letter_branding - - @pytest.mark.parametrize('email_address, organisation_type', ( ("test@example.gov.uk", 'nhs'), ("test@nhs.net", 'nhs'), @@ -155,7 +136,7 @@ def test_create_nhs_service_get_default_branding_based_on_email_address( organisation_type=organisation_type, created_by=user, ) - dao_create_service(service, user, letter_branding=letter_branding) + dao_create_service(service, user) service_db = Service.query.one() if expected_branding: