Created a method to decide which colour to pass into the notifications-utils method to preview the template.

Removed the ServiceCreateEmailBranding form - it is identical to the other form.
This commit is contained in:
Rebecca Law
2018-08-22 12:56:08 +01:00
parent 3fda171f80
commit 473c8378fc
5 changed files with 40 additions and 35 deletions

View File

@@ -4,6 +4,8 @@ import pytest
from bs4 import BeautifulSoup
from flask import url_for
from app.main.views.index import _set_colour
@pytest.mark.parametrize(
"query_args, result", [
@@ -86,7 +88,7 @@ def test_displays_org_branding_with_banner(client, mock_get_email_branding):
assert not page.find("a", attrs={"href": "https://www.gov.uk"})
assert page.find("img", attrs={"src": re.compile("example.png")})
assert page.select("body > table > tr > td[bgcolor='#f00']") # banner colour is set
assert page.select("body > table > tr > td[bgcolor='#f11']") # banner colour is set
assert page.select("body > table table > tr > td > span")[0]\
.get_text().strip() == 'Organisation text' # brand text is set
@@ -104,5 +106,28 @@ def test_displays_org_branding_with_banner_without_brand_text(
assert not page.find("a", attrs={"href": "https://www.gov.uk"})
assert page.find("img", attrs={"src": re.compile("example.png")})
assert page.select("body > table > tr > td[bgcolor='#f00']") # banner colour is set
assert page.select("body > table > tr > td[bgcolor='#f11']") # banner colour is set
assert not page.select("body > table table > tr > td > span") == 0 # brand text is not set
@pytest.mark.parametrize('colour, banner_colour, single_id_colour, branding_type, expected_colour', [
('black', 'yellow', 'red', 'org', 'red'),
('black', 'yellow', None, 'org', 'black'),
('black', 'yellow', 'red', 'org_banner', 'yellow'),
('black', None, 'red', 'org_banner', 'black'),
('black', 'yellow', 'red', 'govuk', None),
('black', 'yellow', 'red', 'both', 'red'),
('black', 'yellow', None, 'both', 'black'),
])
def test_set_colour(colour, banner_colour, single_id_colour, branding_type, expected_colour):
email_branding = {
'logo': None,
'colour': colour,
'text': 'new text',
'name': 'new name',
'domain': 'sample.com',
'banner_colour': banner_colour,
'single_id_colour': single_id_colour,
}
colour = _set_colour(branding_type, email_branding)
assert colour == expected_colour

View File

@@ -2514,7 +2514,9 @@ def mock_get_email_branding_without_brand_text(mocker, fake_uuid):
'name': 'Organisation name',
'text': '',
'id': fake_uuid,
'colour': '#f00'
'colour': '#f00',
'banner_colour': '#f11',
'single_id_colour': '#f22'
}
}