From 46e16c64fc5732673a76432e32485ea3fa20a566 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 19 Feb 2020 17:18:03 +0000 Subject: [PATCH] =?UTF-8?q?Say=20=E2=80=98Uploaded=E2=80=99=20for=20one-of?= =?UTF-8?q?f=20precompiled=20letters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This calls back to what the user has actively done. _Provided as a PDF_ is more passive and suitable for PDF letters sent using the API. --- .../views/notifications/notification.html | 6 ++- tests/app/main/views/test_notifications.py | 45 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/app/templates/views/notifications/notification.html b/app/templates/views/notifications/notification.html index 825adc81f..8aa91cb08 100644 --- a/app/templates/views/notifications/notification.html +++ b/app/templates/views/notifications/notification.html @@ -17,7 +17,11 @@ ) }}

{% if is_precompiled_letter %} - Provided as PDF + {% if created_by %} + Uploaded + {% else %} + Provided as PDF + {% endif %} {% else %} {% if help %} ‘{{ template.name }}’ diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py index 10fc2d4d2..590e61c89 100644 --- a/tests/app/main/views/test_notifications.py +++ b/tests/app/main/views/test_notifications.py @@ -247,6 +247,51 @@ def test_notification_page_shows_page_for_letter_notification( assert mock_page_count.call_args_list[0][1]['values'] == {'name': 'Jo'} +@freeze_time("2020-01-01 00:00") +def test_notification_page_shows_uploaded_letter( + client_request, + mocker, + fake_uuid, +): + mocker.patch( + 'app.main.views.notifications.view_letter_notification_as_preview', + return_value=(b'foo', { + 'message': '', + 'invalid_pages': '[]', + 'page_count': '1' + }) + ) + mocker.patch( + 'app.main.views.notifications.pdf_page_count', + return_value=1 + ) + mocker.patch( + 'app.main.views.notifications.get_page_count_for_letter', + return_value=1, + ) + + notification = create_notification( + notification_status='created', + template_type='letter', + is_precompiled_letter=True, + sent_one_off=True, + ) + mocker.patch('app.notification_api_client.get_notification', return_value=notification) + + page = client_request.get( + 'main.view_notification', + service_id=SERVICE_ONE_ID, + notification_id=fake_uuid, + ) + + assert normalize_spaces(page.select('main p:nth-of-type(1)')[0].text) == ( + 'Uploaded by Test User yesterday at midnight' + ) + assert normalize_spaces(page.select('main p:nth-of-type(2)')[0].text) == ( + 'Printing starts today at 5:30pm' + ) + + @freeze_time("2016-01-01 01:01") @pytest.mark.parametrize('is_precompiled_letter, expected_p1, expected_p2, expected_postage', ( (