diff --git a/tests/app/utils/test_branding.py b/tests/app/utils/test_branding.py index e05007f27..c46a68d94 100644 --- a/tests/app/utils/test_branding.py +++ b/tests/app/utils/test_branding.py @@ -9,6 +9,7 @@ from app.utils.branding import ( get_letter_choices, ) from tests import organisation_json +from tests.conftest import create_email_branding @pytest.mark.parametrize('function', [get_email_choices, get_letter_choices]) @@ -78,6 +79,46 @@ def test_get_email_choices_service_assigned_to_org( assert list(options) == expected_options +@pytest.mark.parametrize('org_type, branding_id, expected_options', [ + ('central', 'some-branding-id', [ + # don't show GOV.UK options as org default supersedes it + ('organisation', 'Test Organisation'), + ]), + ('central', 'org-branding-id', [ + # also don't show org option if it's the current branding + ]), + ('local', 'org-branding-id', [ + # don't show org option if it's the current branding + ]), +]) +def test_get_email_choices_org_has_default_branding( + mocker, + service_one, + org_type, + branding_id, + expected_options, + mock_get_service_organisation, + mock_get_email_branding +): + service = Service(service_one) + + mocker.patch( + 'app.organisations_client.get_organisation', + return_value=organisation_json( + organisation_type=org_type, + email_branding_id='org-branding-id' + ) + ) + mocker.patch( + 'app.models.service.Service.email_branding_id', + new_callable=PropertyMock, + return_value=branding_id + ) + + options = get_email_choices(service) + assert list(options) == expected_options + + @pytest.mark.parametrize('org_type, branding_id, expected_options', [ ('central', None, [ ('organisation', 'Test Organisation') @@ -114,3 +155,39 @@ def test_get_letter_choices_service_assigned_to_org( options = get_letter_choices(service) assert list(options) == expected_options + + +@pytest.mark.parametrize('branding_id, expected_options', [ + ('some-branding-id', [ + # show org option if it's not the current branding + ('organisation', 'Test Organisation'), + ]), + ('org-branding-id', [ + # don't show org option if it's the current branding + ]), +]) +def test_get_letter_choices_org_has_default_branding( + mocker, + service_one, + branding_id, + expected_options, + mock_get_service_organisation, +): + service = Service(service_one) + + mocker.patch( + 'app.organisations_client.get_organisation', + return_value=organisation_json( + organisation_type='central', + letter_branding_id='org-branding-id' + ) + ) + mocker.patch( + 'app.models.service.Service.letter_branding_id', + new_callable=PropertyMock, + return_value=branding_id + ) + + options = get_letter_choices(service) + # don't show org option if it's the current branding + assert list(options) == expected_options