Fix the tests broken by the changes

This commit is contained in:
Tom Byers
2018-08-10 16:57:13 +01:00
parent fafe03e9f0
commit dcb9973f76
3 changed files with 28 additions and 16 deletions

View File

@@ -26,9 +26,7 @@ def test_email_branding_page_shows_full_branding_list(
) == "Select an email branding to update or create a new email branding"
first_label = page.select('div.multiple-choice > label')[0]
assert 'background: red;' in first_label.find('span')['style']
assert normalize_spaces(first_label.text) == 'org 1'
assert first_label.find('img')['src'].endswith('/logo1.png')
assert normalize_spaces((page.select('div.multiple-choice > label')[-1]).text) == 'Create a new email branding'
@@ -47,6 +45,7 @@ def test_edit_email_branding_shows_the_correct_branding_info(
assert page.select_one('#logo-img > img')['src'].endswith('/example.png')
assert page.select_one('#name').attrs.get('value') == 'Organisation name'
assert page.select_one('#text').attrs.get('value') == 'Organisation name'
assert page.select_one('#colour').attrs.get('value') == '#f00'
@@ -64,6 +63,7 @@ def test_create_email_branding_does_not_show_any_branding_info(
assert page.select_one('#logo-img > img') is None
assert page.select_one('#name').attrs.get('value') == ''
assert page.select_one('#text').attrs.get('value') == ''
assert page.select_one('#colour').attrs.get('value') == ''
@@ -76,7 +76,8 @@ def test_create_new_email_branding_without_logo(
data = {
'logo': None,
'colour': '#ff0000',
'name': 'new name'
'text': 'new text',
'name': 'new name',
}
mock_persist = mocker.patch('app.main.views.email_branding.persist_logo')
@@ -92,6 +93,7 @@ def test_create_new_email_branding_without_logo(
assert mock_create_email_branding.call_args == call(
logo=data['logo'],
name=data['name'],
text=data['text'],
colour=data['colour']
)
assert mock_persist.call_args_list == []
@@ -109,7 +111,8 @@ def test_create_new_email_branding_when_branding_saved(
data = {
'logo': 'test.png',
'colour': '#ff0000',
'name': 'new name'
'text': 'new text',
'name': 'new name',
}
temp_filename = LOGO_LOCATION_STRUCTURE.format(
@@ -127,6 +130,7 @@ def test_create_new_email_branding_when_branding_saved(
data={
'colour': data['colour'],
'name': data['name'],
'text': data['text'],
'cdn_url': 'https://static-logos.cdn.com'
}
)
@@ -135,6 +139,7 @@ def test_create_new_email_branding_when_branding_saved(
assert mock_create_email_branding.call_args == call(
logo=data['logo'],
name=data['name'],
text=data['text'],
colour=data['colour']
)
@@ -199,6 +204,7 @@ def test_update_exisiting_branding(
data = {
'logo': 'test.png',
'colour': '#0000ff',
'text': 'new text',
'name': 'new name'
}
@@ -214,7 +220,8 @@ def test_update_exisiting_branding(
logged_in_platform_admin_client.post(
url_for('.update_email_branding', logo=temp_filename, branding_id=fake_uuid),
content_type='multipart/form-data',
data={'colour': data['colour'], 'name': data['name'], 'cdn_url': 'https://static-logos.cdn.com'}
data={'colour': data['colour'], 'name': data['name'], 'text': data['text'],
'cdn_url': 'https://static-logos.cdn.com'}
)
assert mock_update_email_branding.called
@@ -222,6 +229,7 @@ def test_update_exisiting_branding(
branding_id=fake_uuid,
logo=data['logo'],
name=data['name'],
text=data['text'],
colour=data['colour']
)
@@ -303,6 +311,7 @@ def test_colour_regex_validation(
data = {
'logo': None,
'colour': colour_hex,
'text': 'new text',
'name': 'new name'
}

View File

@@ -26,10 +26,11 @@ def test_get_letter_email_branding(mocker):
def test_create_email_branding(mocker):
org_data = {'logo': 'test.png', 'name': 'test name', 'colour': 'red'}
org_data = {'logo': 'test.png', 'name': 'test name', 'text': 'test name', 'colour': 'red'}
mock_post = mocker.patch('app.notify_client.email_branding_client.EmailBrandingClient.post')
EmailBrandingClient().create_email_branding(logo=org_data['logo'], name=org_data['name'], colour=org_data['colour'])
EmailBrandingClient().create_email_branding(
logo=org_data['logo'], name=org_data['name'], text=org_data['text'], colour=org_data['colour'])
mock_post.assert_called_once_with(
url='/email-branding',
@@ -38,11 +39,12 @@ def test_create_email_branding(mocker):
def test_update_email_branding(mocker, fake_uuid):
org_data = {'logo': 'test.png', 'name': 'test name', 'colour': 'red'}
org_data = {'logo': 'test.png', 'name': 'test name', 'text': 'test name', 'colour': 'red'}
mock_post = mocker.patch('app.notify_client.email_branding_client.EmailBrandingClient.post')
EmailBrandingClient().update_email_branding(
branding_id=fake_uuid, logo=org_data['logo'], name=org_data['name'], colour=org_data['colour'])
branding_id=fake_uuid, logo=org_data['logo'], name=org_data['name'], text=org_data['text'],
colour=org_data['colour'])
mock_post.assert_called_once_with(
url='/email-branding/{}'.format(fake_uuid),

View File

@@ -2432,11 +2432,11 @@ def mock_send_already_registered_email(mocker):
def mock_get_all_email_branding(mocker):
def _get_all_email_branding():
return [
{'id': '1', 'name': 'org 1', 'colour': 'red', 'logo': 'logo1.png'},
{'id': '2', 'name': 'org 2', 'colour': 'orange', 'logo': 'logo2.png'},
{'id': '3', 'name': None, 'colour': None, 'logo': 'logo3.png'},
{'id': '4', 'name': 'org 4', 'colour': None, 'logo': 'logo4.png'},
{'id': '5', 'name': None, 'colour': 'blue', 'logo': 'logo5.png'},
{'id': '1', 'name': 'org 1', 'text': 'org 1', 'colour': 'red', 'logo': 'logo1.png'},
{'id': '2', 'name': 'org 2', 'text': 'org 2', 'colour': 'orange', 'logo': 'logo2.png'},
{'id': '3', 'name': 'org 3', 'text': None, 'colour': None, 'logo': 'logo3.png'},
{'id': '4', 'name': 'org 4', 'text': 'org 4', 'colour': None, 'logo': 'logo4.png'},
{'id': '5', 'name': 'org 5', 'text': None, 'colour': 'blue', 'logo': 'logo5.png'},
]
return mocker.patch(
@@ -2474,6 +2474,7 @@ def mock_get_email_branding(mocker, fake_uuid):
'email_branding': {
'logo': 'example.png',
'name': 'Organisation name',
'text': 'Organisation name',
'id': fake_uuid,
'colour': '#f00'
}
@@ -2486,7 +2487,7 @@ def mock_get_email_branding(mocker, fake_uuid):
@pytest.fixture(scope='function')
def mock_create_email_branding(mocker):
def _create_email_branding(logo, name, colour):
def _create_email_branding(logo, name, text, colour):
return
return mocker.patch(
@@ -2496,7 +2497,7 @@ def mock_create_email_branding(mocker):
@pytest.fixture(scope='function')
def mock_update_email_branding(mocker):
def _update_email_branding(branding_id, logo, name, colour):
def _update_email_branding(branding_id, logo, name, text, colour):
return
return mocker.patch(