diff --git a/app/main/views/notifications.py b/app/main/views/notifications.py index 9ec77aeb8..f1e594357 100644 --- a/app/main/views/notifications.py +++ b/app/main/views/notifications.py @@ -90,7 +90,10 @@ def view_notification(service_id, notification_id): created_by=notification.get('created_by'), created_at=notification['created_at'], help=get_help_argument(), - estimated_letter_delivery_date=get_letter_timings(notification['created_at']).earliest_delivery, + estimated_letter_delivery_date=get_letter_timings( + notification['created_at'], + postage=notification['postage'] + ).earliest_delivery, notification_id=notification['id'], postage=notification['postage'], can_receive_inbound=(current_service.has_permission('inbound_sms')), diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py index 3c53ebf9f..5a6bdd418 100644 --- a/tests/app/main/views/test_notifications.py +++ b/tests/app/main/views/test_notifications.py @@ -141,7 +141,7 @@ def test_notification_page_shows_page_for_letter_notification( count_of_pages = 3 - mock_get_notification(mocker, fake_uuid, template_type='letter') + mock_get_notification(mocker, fake_uuid, template_type='letter', postage='second') mocker.patch( 'app.main.views.notifications.get_page_count_for_letter', return_value=count_of_pages @@ -174,6 +174,25 @@ def test_notification_page_shows_page_for_letter_notification( ) +@freeze_time("2016-01-01 01:01") +def test_notification_page_shows_page_for_first_class_letter_notification( + client_request, + mocker, + fake_uuid, +): + mock_get_notification(mocker, fake_uuid, template_type='letter', postage='first') + mocker.patch('app.main.views.notifications.get_page_count_for_letter', return_value=3) + + 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(2)')[0].text) == 'Postage: first class' + assert normalize_spaces(page.select('main p:nth-of-type(3)')[0].text) == 'Estimated delivery date: 5 January' + + @pytest.mark.parametrize('filetype', [ 'pdf', 'png' ]) diff --git a/tests/conftest.py b/tests/conftest.py index c00bfd387..66cd2ccce 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2645,6 +2645,7 @@ def mock_get_notification( template_name='sample template', is_precompiled_letter=False, key_type=None, + postage=None ): def _get_notification( service_id, @@ -2655,6 +2656,7 @@ def mock_get_notification( rows=1, status=notification_status, template_type=template_type, + postage=postage )['notifications'][0] noti['id'] = notification_id