mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 01:18:24 -04:00
Add a page to set organisation and branding option
Platform admin only. Adds radio buttons to choose one of: - three hard-coded branding options - organisations from a list provided by the API
This commit is contained in:
committed by
Leo Hemsted
parent
20c39d24b7
commit
6b5e64479a
@@ -759,3 +759,61 @@ def test_set_text_message_sender_flash_messages(
|
||||
element = page.find('div', {"class": "banner-default-with-tick"})
|
||||
|
||||
assert element.text.strip() == expected_flash_message
|
||||
|
||||
|
||||
def test_should_show_branding_and_organisations(
|
||||
mocker, app_, platform_admin_user, service_one, mock_get_organisations
|
||||
):
|
||||
with app_.test_request_context(), app_.test_client() as client:
|
||||
client.login(platform_admin_user, mocker, service_one)
|
||||
response = client.get(url_for(
|
||||
'main.service_set_branding_and_org', 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-0"})['checked'] == ''
|
||||
assert page.find('input', attrs={"id": "branding_type-1"})['value'] == 'both'
|
||||
with pytest.raises(KeyError):
|
||||
page.find('input', attrs={"id": "branding_type-1"})['checked']
|
||||
assert page.find('input', attrs={"id": "branding_type-2"})['value'] == 'org'
|
||||
with pytest.raises(KeyError):
|
||||
page.find('input', attrs={"id": "branding_type-2"})['checked']
|
||||
|
||||
assert page.find('label', attrs={"for": "organisation-1"}).text.strip() == 'None'
|
||||
with pytest.raises(KeyError):
|
||||
page.find('input', attrs={"id": "organisation-1"})['value']
|
||||
assert page.find('label', attrs={"for": "organisation-2"}).text.strip() == 'Organisation name'
|
||||
assert page.find('label', attrs={"for": "organisation-2"}).find('img')['src'] == (
|
||||
'/static/images/email-template/crests/example.png'
|
||||
)
|
||||
assert '#f00' in str(page.find('label', attrs={"for": "organisation-2"}))
|
||||
|
||||
app.organisations_client.get_organisations.assert_called_once_with()
|
||||
app.service_api_client.get_service.assert_called_once_with(service_one['id'])
|
||||
|
||||
|
||||
def test_should_set_branding_and_organisations(
|
||||
mocker, app_, platform_admin_user, service_one, mock_get_organisations, mock_update_service
|
||||
):
|
||||
with app_.test_request_context(), app_.test_client() as client:
|
||||
client.login(platform_admin_user, mocker, service_one)
|
||||
response = client.post(
|
||||
url_for(
|
||||
'main.service_set_branding_and_org', service_id=service_one['id']
|
||||
),
|
||||
data={
|
||||
'branding_type': 'org',
|
||||
'organisation': 'organisation-name'
|
||||
}
|
||||
)
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('main.service_settings', service_id=service_one['id'], _external=True)
|
||||
|
||||
app.organisations_client.get_organisations.assert_called_once_with()
|
||||
app.service_api_client.update_service.assert_called_once_with(
|
||||
service_one['id'],
|
||||
branding='org',
|
||||
organisation='organisation-name'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user