Merge pull request #2262 from alphagov/remove_branding_type_from_set_email_branding_page

Remove branding type from set email branding page
This commit is contained in:
Tom Byers
2018-08-31 13:56:44 +01:00
committed by GitHub
9 changed files with 123 additions and 110 deletions

View File

@@ -32,9 +32,9 @@ def test_displays_govuk_branding_by_default(client):
assert page.find("a", attrs={"href": "https://www.gov.uk"})
def test_displays_govuk_branding(client):
def test_displays_govuk_branding(client, mock_get_email_branding_with_govuk_brand_type):
response = client.get(url_for('main.email_template', branding_type="govuk", branding_style="1"))
response = client.get(url_for('main.email_template', branding_style="1"))
page = BeautifulSoup(response.data.decode("utf-8"), "html.parser")
@@ -43,14 +43,14 @@ def test_displays_govuk_branding(client):
assert page.find("a", attrs={"href": "https://www.gov.uk"})
def test_displays_both_branding(client, mock_get_email_branding):
def test_displays_both_branding(client, mock_get_email_branding_with_both_brand_type):
response = client.get(url_for('main.email_template', branding_type="both", branding_style="1"))
response = client.get(url_for('main.email_template', branding_style="1"))
page = BeautifulSoup(response.data.decode("utf-8"), "html.parser")
assert response.status_code == 200
mock_get_email_branding.assert_called_once_with('1')
mock_get_email_branding_with_both_brand_type.assert_called_once_with('1')
assert page.find("a", attrs={"href": "https://www.gov.uk"})
assert page.find("img", attrs={"src": re.compile("example.png$")})
@@ -60,7 +60,8 @@ def test_displays_both_branding(client, mock_get_email_branding):
def test_displays_org_branding(client, mock_get_email_branding):
response = client.get(url_for('main.email_template', branding_type="org", branding_style="1"))
# mock_get_email_branding has 'brand_type' of 'org'
response = client.get(url_for('main.email_template', branding_style="1"))
page = BeautifulSoup(response.data.decode("utf-8"), "html.parser")
@@ -74,15 +75,15 @@ def test_displays_org_branding(client, mock_get_email_branding):
.get_text().strip() == 'Organisation text' # brand text is set
def test_displays_org_branding_with_banner(client, mock_get_email_branding):
def test_displays_org_branding_with_banner(
client, mock_get_email_branding_with_org_banner_brand_type):
response = client.get(url_for('main.email_template', branding_type="org_banner",
branding_style="1"))
response = client.get(url_for('main.email_template', branding_style="1"))
page = BeautifulSoup(response.data.decode("utf-8"), "html.parser")
assert response.status_code == 200
mock_get_email_branding.assert_called_once_with('1')
mock_get_email_branding_with_org_banner_brand_type.assert_called_once_with('1')
assert not page.find("a", attrs={"href": "https://www.gov.uk"})
assert page.find("img", attrs={"src": re.compile("example.png")})
@@ -94,8 +95,8 @@ def test_displays_org_branding_with_banner(client, mock_get_email_branding):
def test_displays_org_branding_with_banner_without_brand_text(
client, mock_get_email_branding_without_brand_text):
response = client.get(url_for('main.email_template', branding_type="org_banner",
branding_style="1"))
# mock_get_email_branding_without_brand_text has 'brand_type' of 'org_banner'
response = client.get(url_for('main.email_template', branding_style="1"))
page = BeautifulSoup(response.data.decode("utf-8"), "html.parser")

View File

@@ -1846,31 +1846,6 @@ def test_set_letter_branding_saves(
mock_update_service.assert_called_once_with(service_one['id'], dvla_organisation='500')
def test_should_show_branding_types(
logged_in_platform_admin_client,
service_one,
mock_get_all_email_branding,
):
response = logged_in_platform_admin_client.get(url_for(
'main.service_set_email_branding', service_id=service_one['id']
))
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert page.find('input', attrs={"id": "branding_type-0"})['value'] == 'govuk'
assert page.find('input', attrs={"id": "branding_type-1"})['value'] == 'both'
assert page.find('input', attrs={"id": "branding_type-2"})['value'] == 'org'
assert page.find('input', attrs={"id": "branding_type-3"})['value'] == 'org_banner'
assert 'checked' in page.find('input', attrs={"id": "branding_type-0"}).attrs
assert 'checked' not in page.find('input', attrs={"id": "branding_type-1"}).attrs
assert 'checked' not in page.find('input', attrs={"id": "branding_type-2"}).attrs
assert 'checked' not in page.find('input', attrs={"id": "branding_type-3"}).attrs
app.email_branding_client.get_all_email_branding.assert_called_once_with()
app.service_api_client.get_service.assert_called_once_with(service_one['id'])
def test_should_show_branding_styles(
logged_in_platform_admin_client,
service_one,
@@ -1897,7 +1872,7 @@ def test_should_show_branding_styles(
assert branding_style_choices[5]['value'] == '5'
# radios should be in alphabetical order, based on their labels
assert radio_labels == ['None', 'org 1', 'org 2', 'org 3', 'org 4', 'org 5']
assert radio_labels == ['GOV.UK', 'org 1', 'org 2', 'org 3', 'org 4', 'org 5']
assert 'checked' in branding_style_choices[0].attrs
assert 'checked' not in branding_style_choices[1].attrs
@@ -1955,8 +1930,8 @@ def test_should_send_branding_and_organisations_to_preview(
)
assert response.status_code == 302
assert response.location == url_for('main.service_preview_email_branding',
service_id=service_one['id'], branding_type='org',
branding_style='1', _external=True)
service_id=service_one['id'], branding_style='1',
_external=True)
mock_get_all_email_branding.assert_called_once_with()
@@ -1975,10 +1950,8 @@ def test_should_preview_email_branding(
iframeURLComponents = urlparse(iframe['src'])
iframeQString = parse_qs(iframeURLComponents.query)
assert page.find('input', attrs={"id": "branding_type"})['value'] == 'org'
assert page.find('input', attrs={"id": "branding_style"})['value'] == '1'
assert iframeURLComponents.path == '/_email'
assert iframeQString['branding_type'] == ['org']
assert iframeQString['branding_style'] == ['1']
app.service_api_client.get_service.assert_called_once_with(service_one['id'])
@@ -1994,7 +1967,6 @@ def test_should_set_branding_and_organisations(
'main.service_preview_email_branding', service_id=service_one['id']
),
data={
'branding_type': 'org',
'branding_style': '1'
}
)
@@ -2004,7 +1976,6 @@ def test_should_set_branding_and_organisations(
mock_update_service.assert_called_once_with(
service_one['id'],
branding='org',
email_branding='1'
)
@@ -2886,13 +2857,16 @@ 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
):
page = client_request.get(
'.branding_request', service_id=SERVICE_ONE_ID
)
mock_get_email_branding.assert_not_called()
radios = page.select('input[type=radio]')
for index, option in enumerate((
@@ -2905,6 +2879,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'),