mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Updated so that a precompiled pdf page count can be passed to the
rendering template. Currently it uses the template from the API to calculate this which for a precompiled template is always 1. Gets the PDF and then uses the utils method to get the page count. * Added logic for precompiled letters * Added test to test the new path * Updated existing tests now the path has changed
This commit is contained in:
@@ -320,8 +320,19 @@ def test_notification_page_has_expected_template_link_for_letter(
|
||||
has_template_link
|
||||
):
|
||||
|
||||
mocker.patch(
|
||||
'app.main.views.notifications.view_letter_notification_as_preview',
|
||||
return_value=b'foo'
|
||||
)
|
||||
|
||||
mocker.patch(
|
||||
'app.main.views.notifications.pdf_page_count',
|
||||
return_value=1
|
||||
)
|
||||
|
||||
mock_get_notification(
|
||||
mocker, fake_uuid, template_type='letter', is_precompiled_letter=is_precompiled_letter)
|
||||
|
||||
mocker.patch(
|
||||
'app.main.views.notifications.get_page_count_for_letter',
|
||||
return_value=1
|
||||
@@ -339,3 +350,35 @@ def test_notification_page_has_expected_template_link_for_letter(
|
||||
assert link
|
||||
else:
|
||||
assert link is None
|
||||
|
||||
|
||||
def test_should_show_image_of_precompiled_letter_notification(
|
||||
logged_in_client,
|
||||
fake_uuid,
|
||||
mocker,
|
||||
):
|
||||
|
||||
mock_get_notification(mocker, fake_uuid, template_type='letter', is_precompiled_letter=True)
|
||||
|
||||
mock_pdf_page_count = mocker.patch(
|
||||
'app.main.views.notifications.pdf_page_count',
|
||||
return_value=1
|
||||
)
|
||||
|
||||
mocker.patch(
|
||||
'app.notify_client.notification_api_client.NotificationApiClient.get',
|
||||
return_value={
|
||||
'content': base64.b64encode(b'foo').decode('utf-8')
|
||||
}
|
||||
)
|
||||
|
||||
response = logged_in_client.get(url_for(
|
||||
'main.view_letter_notification_as_preview',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
filetype="png"
|
||||
))
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.get_data(as_text=True) == 'foo'
|
||||
assert mock_pdf_page_count.called_once()
|
||||
|
||||
Reference in New Issue
Block a user