mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -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
@@ -49,7 +49,9 @@ def service_json(
|
||||
email_from=None,
|
||||
reply_to_email_address=None,
|
||||
sms_sender=None,
|
||||
research_mode=False
|
||||
research_mode=False,
|
||||
organisation='organisation-name',
|
||||
branding='govuk'
|
||||
):
|
||||
return {
|
||||
'id': id_,
|
||||
@@ -61,7 +63,9 @@ def service_json(
|
||||
'email_from': email_from,
|
||||
'reply_to_email_address': reply_to_email_address,
|
||||
'sms_sender': sms_sender,
|
||||
'research_mode': research_mode
|
||||
'research_mode': research_mode,
|
||||
'organisation': organisation,
|
||||
'branding': branding
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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'
|
||||
)
|
||||
|
||||
@@ -1133,3 +1133,20 @@ def mock_events(mocker):
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_send_already_registered_email(mocker):
|
||||
return mocker.patch('app.user_api_client.send_already_registered_email')
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_organisations(mocker):
|
||||
def _get_organisations():
|
||||
return [
|
||||
{
|
||||
'logo': 'example.png',
|
||||
'name': 'Organisation name',
|
||||
'id': 'organisation-name',
|
||||
'colour': '#f00'
|
||||
}
|
||||
]
|
||||
|
||||
return mocker.patch(
|
||||
'app.organisations_client.get_organisations', side_effect=_get_organisations
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user