mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-17 03:40:41 -04:00
Migrate two more tests to the branding utility
All of the mock / UI assertions in these tests are covered by the tests above them - these tests were mostly targetting which options were being shown, which we can check at a lower level.
This commit is contained in:
@@ -4850,117 +4850,6 @@ def test_letter_branding_request_page_when_no_branding_is_set(
|
||||
assert not page.select('.conditional-radios-panel')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('branding_type', ['email', 'letter'])
|
||||
@pytest.mark.parametrize('organisation_type, expected_options', (
|
||||
('local', [
|
||||
('organisation', 'Test Organisation'),
|
||||
('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', [
|
||||
('organisation', 'Test Organisation'),
|
||||
('something_else', 'Something else'),
|
||||
]),
|
||||
('other', [
|
||||
('organisation', 'Test Organisation'),
|
||||
('something_else', 'Something else'),
|
||||
]),
|
||||
))
|
||||
def test_branding_request_page_when_no_branding_is_set_but_organisation_exists(
|
||||
mocker,
|
||||
service_one,
|
||||
client_request,
|
||||
mock_get_email_branding,
|
||||
mock_get_letter_branding_by_id,
|
||||
mock_get_service_organisation,
|
||||
organisation_type,
|
||||
expected_options,
|
||||
branding_type
|
||||
):
|
||||
service_one['{}_branding'.format(branding_type)] = None
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
return_value=organisation_json(organisation_type=organisation_type),
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
f'.{branding_type}_branding_request', service_id=SERVICE_ONE_ID
|
||||
)
|
||||
|
||||
assert mock_get_email_branding.called is False
|
||||
assert mock_get_letter_branding_by_id.called is False
|
||||
|
||||
assert [
|
||||
(
|
||||
radio['value'],
|
||||
page.select_one('label[for={}]'.format(radio['id'])).text.strip()
|
||||
)
|
||||
for radio in page.select('input[type=radio]')
|
||||
] == expected_options
|
||||
|
||||
button_text = normalize_spaces(page.select_one('.page-footer button').text)
|
||||
|
||||
if branding_type == 'email':
|
||||
assert button_text == 'Continue'
|
||||
else:
|
||||
assert button_text == 'Request new branding'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('organisation_type, expected_options, branding_type', (
|
||||
('central', [
|
||||
('govuk_and_org', 'GOV.UK and Test Organisation'),
|
||||
('organisation', 'Test Organisation'),
|
||||
('something_else', 'Something else'),
|
||||
], 'email'),
|
||||
('central', [
|
||||
('organisation', 'Test Organisation'),
|
||||
('something_else', 'Something else'),
|
||||
], 'letter'),
|
||||
))
|
||||
def test_branding_request_page_when_no_branding_is_set_but_organisation_exists_central_org(
|
||||
mocker,
|
||||
service_one,
|
||||
client_request,
|
||||
mock_get_email_branding,
|
||||
mock_get_letter_branding_by_id,
|
||||
mock_get_service_organisation,
|
||||
organisation_type,
|
||||
expected_options,
|
||||
branding_type
|
||||
):
|
||||
service_one['{}_branding'.format(branding_type)] = None
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
return_value=organisation_json(organisation_type=organisation_type),
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
f'.{branding_type}_branding_request', service_id=SERVICE_ONE_ID
|
||||
)
|
||||
|
||||
assert mock_get_email_branding.called is False
|
||||
assert mock_get_letter_branding_by_id.called is False
|
||||
|
||||
assert [
|
||||
(
|
||||
radio['value'],
|
||||
page.select_one('label[for={}]'.format(radio['id'])).text.strip()
|
||||
)
|
||||
for radio in page.select('input[type=radio]')
|
||||
] == expected_options
|
||||
|
||||
|
||||
def test_email_branding_request_page_when_email_branding_is_set(
|
||||
mocker,
|
||||
service_one,
|
||||
|
||||
@@ -2,6 +2,7 @@ import pytest
|
||||
|
||||
from app.models.service import Service
|
||||
from app.utils.branding import get_available_choices
|
||||
from tests import organisation_json
|
||||
|
||||
|
||||
@pytest.mark.parametrize('branding_type', ['email', 'letter'])
|
||||
@@ -26,3 +27,59 @@ def test_get_available_choices_no_org(
|
||||
|
||||
options = get_available_choices(service, branding_type=branding_type)
|
||||
assert list(options) == expected_options
|
||||
|
||||
|
||||
@pytest.mark.parametrize('branding_type', ['email', 'letter'])
|
||||
@pytest.mark.parametrize('org_type, existing_branding, expected_options', [
|
||||
('local', None, [('organisation', 'Test Organisation')]),
|
||||
('nhs_central', None, [('nhs', 'NHS')]),
|
||||
('nhs_local', None, [('nhs', 'NHS')]),
|
||||
('nhs_gp', None, [('nhs', 'NHS')]),
|
||||
('emergency_service', None, [('organisation', 'Test Organisation')]),
|
||||
('other', None, [('organisation', 'Test Organisation')]),
|
||||
])
|
||||
def test_get_available_choices_with_org(
|
||||
mocker,
|
||||
service_one,
|
||||
branding_type,
|
||||
org_type,
|
||||
existing_branding,
|
||||
expected_options,
|
||||
mock_get_service_organisation,
|
||||
):
|
||||
service = Service(service_one)
|
||||
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
return_value=organisation_json(organisation_type=org_type)
|
||||
)
|
||||
|
||||
options = get_available_choices(service, branding_type=branding_type)
|
||||
assert list(options) == expected_options
|
||||
|
||||
|
||||
@pytest.mark.parametrize('branding_type, expected_options', [
|
||||
('email', [
|
||||
('govuk_and_org', 'GOV.UK and Test Organisation'),
|
||||
('organisation', 'Test Organisation'),
|
||||
]),
|
||||
('letter', [
|
||||
('organisation', 'Test Organisation'),
|
||||
])
|
||||
])
|
||||
def test_get_available_choices_with_central_org(
|
||||
mocker,
|
||||
service_one,
|
||||
branding_type,
|
||||
expected_options,
|
||||
mock_get_service_organisation,
|
||||
):
|
||||
service = Service(service_one)
|
||||
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
return_value=organisation_json(organisation_type='central'),
|
||||
)
|
||||
|
||||
options = get_available_choices(service, branding_type=branding_type)
|
||||
assert list(options) == expected_options
|
||||
|
||||
Reference in New Issue
Block a user