Don't fallback to dvla_organisation if letter branding unset

The template preview app now accepts a null value for the `filename` 
parameter. If a service doesn't have a letter branding option set, 
previously we defaulted to their dvla_organisation (probably HM 
Government). Now, we pass through None, so that we generate letters 
without any logo or branding.
This commit is contained in:
Leo Hemsted
2019-02-12 15:47:50 +00:00
parent a8ee92cf03
commit afc5c96927
6 changed files with 10 additions and 16 deletions

View File

@@ -182,8 +182,7 @@ def test_create_letters_pdf_sets_technical_failure_max_retries(mocker, sample_le
mock_update_noti.assert_called_once_with(sample_letter_notification.id, 'technical-failure')
# We only need this while we are migrating to the new letter_branding model
def test_create_letters_gets_the_right_logo_when_service_has_dvla_logo(
def test_create_letters_gets_the_right_logo_when_service_has_no_logo(
notify_api, mocker, sample_letter_notification
):
mock_get_letters_pdf = mocker.patch('app.celery.letters_pdf_tasks.get_letters_pdf', return_value=(b'\x00\x01', 1))
@@ -194,7 +193,7 @@ def test_create_letters_gets_the_right_logo_when_service_has_dvla_logo(
mock_get_letters_pdf.assert_called_once_with(
sample_letter_notification.template,
contact_block=sample_letter_notification.reply_to_text,
filename=sample_letter_notification.service.dvla_organisation.filename,
filename=None,
values=sample_letter_notification.personalisation
)

View File

@@ -141,7 +141,7 @@ def test_get_service_by_id(admin_request, sample_service):
assert 'branding' not in json_resp['data']
assert json_resp['data']['dvla_organisation'] == '001'
assert json_resp['data']['prefix_sms'] is True
assert json_resp['data']['letter_logo_filename'] == 'hm-government'
assert json_resp['data']['letter_logo_filename'] is None
@pytest.mark.parametrize('detailed', [True, False])
@@ -294,10 +294,10 @@ def test_create_service_with_no_domain_doesnt_set_letter_branding(admin_request,
json_resp = admin_request.post('service.create_service', _data=data, _expected_status=201)
assert json_resp['data']['letter_branding'] is None
assert json_resp['data']['letter_logo_filename'] == 'hm-government'
assert json_resp['data']['letter_logo_filename'] is None
def test_get_service_by_id_returns_letter_branding_not_dvla_organisation(
def test_get_service_by_id_returns_letter_branding(
client, sample_service
):
letter_branding = create_letter_branding(

View File

@@ -982,6 +982,7 @@ def test_preview_letter_template_by_id_valid_file_type(
'postcode': 'A_POST',
}
assert post_json['date'] == '2012-12-12T00:00:00'
assert post_json['filename'] is None
assert base64.b64decode(resp['content']) == content