Moved the call to retrieve the pdf into the is_precompiled_letter block

as it did not need to be called for standard letters.

Changed the tests to use the mock from get_notification_letter_preview
instead of a generic NotificationApiClient.get. This will hopefully
protect any subsequent changes or calls from not being tested in future.
This commit is contained in:
Richard Chapman
2018-03-09 13:28:16 +00:00
parent e25c6cd3b9
commit 86a474ce8b
2 changed files with 4 additions and 5 deletions

View File

@@ -46,9 +46,8 @@ def view_notification(service_id, notification_id):
notification = notification_api_client.get_notification(service_id, str(notification_id))
notification['template'].update({'reply_to_text': notification['reply_to_text']})
file_contents = view_letter_notification_as_preview(service_id, notification_id, "pdf")
if notification['template']['is_precompiled_letter']:
file_contents = view_letter_notification_as_preview(service_id, notification_id, "pdf")
page_count = pdf_page_count(io.BytesIO(file_contents))
else:
page_count = get_page_count_for_letter(notification['template'])