Add tests for changes to brand request page

Tests the new code that gets the brand type from
the email_branding model. Includes checks for a
service without the email_branding field set.

It also amends the test for a POST from that page,
removing mocking of the email_branding client.
This test runs against the default service which
has its email_branding field set to None so no
call is made to the client. It's testing the
brand_type values selected so doesn't need the
service to have an email_branding already set.
This commit is contained in:
Tom Byers
2018-08-30 15:48:51 +01:00
parent c2075b6d71
commit 4f67502806

View File

@@ -2729,7 +2729,7 @@ def test_update_service_organisation_does_not_update_if_same_value(
mock_update_service_organisation.called is False
def test_show_email_branding_request_page(
def test_show_email_branding_request_page_when_no_email_branding_is_set(
client_request,
mock_get_email_branding
):
@@ -2737,7 +2737,7 @@ def test_show_email_branding_request_page(
'.branding_request', service_id=SERVICE_ONE_ID
)
mock_get_email_branding.called_once_with(None)
mock_get_email_branding.assert_not_called()
radios = page.select('input[type=radio]')
@@ -2751,6 +2751,35 @@ def test_show_email_branding_request_page(
assert radios[index]['value'] == option
def test_show_email_branding_request_page_when_email_branding_is_set(
client_request,
mock_get_email_branding,
active_user_with_permissions,
):
service_one = service_json(email_branding='1234')
client_request.login(active_user_with_permissions, service=service_one)
page = client_request.get(
'.branding_request', service_id=SERVICE_ONE_ID
)
mock_get_email_branding.called_once_with('1234')
radios = page.select('input[type=radio]')
for index, option in enumerate((
'govuk',
'both',
'org',
'org_banner',
)):
assert radios[index]['name'] == 'options'
assert radios[index]['value'] == option
if option == 'org':
assert 'checked' in radios[index].attrs
@pytest.mark.parametrize('choice, requested_branding', (
('govuk', 'GOV.UK only'),
('both', 'GOV.UK and logo'),
@@ -2770,11 +2799,6 @@ def test_submit_email_branding_request(
single_sms_sender,
):
email_branding_client = mocker.patch(
'app.email_branding_client.get_email_branding',
return_value={'email_branding': {'brand_type': choice}}
)
zendesk = mocker.patch(
'app.main.views.service_settings.zendesk_client.create_ticket',
autospec=True,
@@ -2788,8 +2812,6 @@ def test_submit_email_branding_request(
_follow_redirects=True,
)
email_branding_client.assert_called_once_with(None)
zendesk.assert_called_once_with(
message='\n'.join([
'Organisation: Cant tell (domain is user.gov.uk)',