diff --git a/app/main/views/notifications.py b/app/main/views/notifications.py index 07bbb9b35..2a533bc30 100644 --- a/app/main/views/notifications.py +++ b/app/main/views/notifications.py @@ -134,6 +134,14 @@ def view_notification(service_id, notification_id): status='sending,delivered,failed', ) + if notification['notification_type'] == 'letter': + estimated_letter_delivery_date = get_letter_timings( + notification['created_at'], + postage=notification['postage'] + ).earliest_delivery + else: + estimated_letter_delivery_date = None + return render_template( 'views/notifications/notification.html', finished=(notification['status'] in (DELIVERED_STATUSES + FAILURE_STATUSES)), @@ -154,10 +162,7 @@ def view_notification(service_id, notification_id): created_at=notification['created_at'], updated_at=notification['updated_at'], help=get_help_argument(), - estimated_letter_delivery_date=get_letter_timings( - notification['created_at'], - postage=notification['postage'] - ).earliest_delivery, + estimated_letter_delivery_date=estimated_letter_delivery_date, notification_id=notification['id'], postage=notification['postage'], can_receive_inbound=(current_service.has_permission('inbound_sms')), diff --git a/requirements-app.txt b/requirements-app.txt index 80a3f30f7..e70659ff1 100644 --- a/requirements-app.txt +++ b/requirements-app.txt @@ -23,5 +23,5 @@ notifications-python-client==5.5.1 awscli-cwlogs>=1.4,<1.5 itsdangerous==1.1.0 -git+https://github.com/alphagov/notifications-utils.git@39.3.0#egg=notifications-utils==39.3.0 +git+https://github.com/alphagov/notifications-utils.git@39.4.2#egg=notifications-utils==39.4.2 git+https://github.com/alphagov/govuk-frontend-jinja.git@v0.5.1-alpha#egg=govuk-frontend-jinja==0.5.1-alpha diff --git a/requirements.txt b/requirements.txt index f5d52fee8..196fce3b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,14 +25,14 @@ notifications-python-client==5.5.1 awscli-cwlogs>=1.4,<1.5 itsdangerous==1.1.0 -git+https://github.com/alphagov/notifications-utils.git@39.3.0#egg=notifications-utils==39.3.0 +git+https://github.com/alphagov/notifications-utils.git@39.4.2#egg=notifications-utils==39.4.2 git+https://github.com/alphagov/govuk-frontend-jinja.git@v0.5.1-alpha#egg=govuk-frontend-jinja==0.5.1-alpha ## The following requirements were added by pip freeze: -awscli==1.18.63 +awscli==1.18.67 bleach==3.1.4 boto3==1.10.38 -botocore==1.16.13 +botocore==1.16.17 certifi==2020.4.5.1 chardet==3.0.4 click==7.1.2 @@ -67,7 +67,7 @@ redis==3.5.2 requests==2.23.0 rsa==3.4.2 s3transfer==0.3.3 -six==1.14.0 +six==1.15.0 smartypants==2.0.1 statsd==3.3.0 texttable==1.6.2 diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 8a81153b4..996d77dcc 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -349,13 +349,17 @@ def test_should_show_letter_job( @freeze_time("2016-01-01 11:09:00") def test_should_show_letter_job_with_banner_after_sending_before_1730( + mocker, client_request, mock_get_service_letter_template, mock_get_letter_job, - mock_get_notifications, mock_get_service_data_retention, fake_uuid, ): + mocker.patch( + 'app.notification_api_client.get_notifications_for_service', + return_value=create_notifications(template_type='letter', postage='second') + ) page = client_request.get( 'main.view_job', @@ -373,13 +377,17 @@ def test_should_show_letter_job_with_banner_after_sending_before_1730( @freeze_time("2016-01-01 11:09:00") def test_should_show_letter_job_with_banner_when_there_are_multiple_CSV_rows( + mocker, client_request, mock_get_service_letter_template, mock_get_letter_job_in_progress, - mock_get_notifications, mock_get_service_data_retention, fake_uuid, ): + mocker.patch( + 'app.notification_api_client.get_notifications_for_service', + return_value=create_notifications(template_type='letter', postage='second') + ) page = client_request.get( 'main.view_job', @@ -396,13 +404,17 @@ def test_should_show_letter_job_with_banner_when_there_are_multiple_CSV_rows( @freeze_time("2016-01-01 18:09:00") def test_should_show_letter_job_with_banner_after_sending_after_1730( + mocker, client_request, mock_get_service_letter_template, mock_get_letter_job, - mock_get_notifications, mock_get_service_data_retention, fake_uuid, ): + mocker.patch( + 'app.notification_api_client.get_notifications_for_service', + return_value=create_notifications(template_type='letter', postage='second') + ) page = client_request.get( 'main.view_job', diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py index f4b70e642..625048c9c 100644 --- a/tests/app/main/views/test_notifications.py +++ b/tests/app/main/views/test_notifications.py @@ -530,13 +530,13 @@ def test_notification_page_does_not_show_cancel_link_for_letter_which_cannot_be_ 'europe', 'Postage: international', 'letter-postage-international', - 'Estimated delivery date: Wednesday 6 January', + 'Estimated delivery date: Friday 8 January', ), ( 'rest-of-world', 'Postage: international', 'letter-postage-international', - 'Estimated delivery date: Wednesday 6 January', + 'Estimated delivery date: Monday 11 January', ), )) @freeze_time("2016-01-01 18:00")