From 1946d3c92809ba43066edb649dd5fe96aba11071 Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Thu, 3 Mar 2022 12:54:57 +0000 Subject: [PATCH] Migrate two branding tests to utils module This is much simpler than trying to test the function via the page, although there are still two scenarios to test there: - The page with radio buttons (using NHS as an example). - The page with a text form (using "other" as an example). In future work we could split this test in two to make it clearer what it's trying to test. For now, this keeps the diff simple. --- tests/app/main/views/test_service_settings.py | 28 ------------------- tests/app/utils/test_branding.py | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 tests/app/utils/test_branding.py diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index f26fcf125..ac0ca5cf8 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -4753,27 +4753,10 @@ def test_update_service_organisation_does_not_update_if_same_value( @pytest.mark.parametrize('organisation_type, expected_options', ( - ('central', [ - ('something_else', 'Something else'), - ]), - ('local', [ - ('something_else', 'Something else'), - ]), ('nhs_central', [ ('nhs', 'NHS'), ('something_else', 'Something else'), ]), - ('nhs_local', [ - ('nhs', 'NHS'), - ('something_else', 'Something else'), - ]), - ('nhs_gp', [ - ('nhs', 'NHS'), - ('something_else', 'Something else'), - ]), - ('emergency_service', [ - ('something_else', 'Something else'), - ]), ('other', [ ('something_else', 'Something else'), ]) @@ -4818,21 +4801,10 @@ def test_email_branding_request_page_when_no_branding_is_set( @pytest.mark.parametrize('organisation_type, expected_options', ( - ('central', None), - ('local', None), ('nhs_central', [ ('nhs', 'NHS'), ('something_else', 'Something else'), ]), - ('nhs_local', [ - ('nhs', 'NHS'), - ('something_else', 'Something else'), - ]), - ('nhs_gp', [ - ('nhs', 'NHS'), - ('something_else', 'Something else'), - ]), - ('emergency_service', None), ('other', None), )) def test_letter_branding_request_page_when_no_branding_is_set( diff --git a/tests/app/utils/test_branding.py b/tests/app/utils/test_branding.py new file mode 100644 index 000000000..2dfab64f3 --- /dev/null +++ b/tests/app/utils/test_branding.py @@ -0,0 +1,28 @@ +import pytest + +from app.models.service import Service +from app.utils.branding import get_available_choices + + +@pytest.mark.parametrize('branding_type', ['email', 'letter']) +@pytest.mark.parametrize('org_type, existing_branding, expected_options', [ + ('central', None, []), + ('local', None, []), + ('nhs_central', None, [('nhs', 'NHS')]), + ('nhs_local', None, [('nhs', 'NHS')]), + ('nhs_gp', None, [('nhs', 'NHS')]), + ('emergency_service', None, []), + ('other', None, []), +]) +def test_get_available_choices_no_org( + service_one, + branding_type, + org_type, + existing_branding, + expected_options, +): + service_one['organisation_type'] = org_type + service = Service(service_one) + + options = get_available_choices(service, branding_type=branding_type) + assert list(options) == expected_options