diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py
index 394b98d72..81a1facb3 100644
--- a/app/main/views/jobs.py
+++ b/app/main/views/jobs.py
@@ -355,20 +355,14 @@ def get_job_partials(job):
filter_args = parse_filter_args(request.args)
filter_args['status'] = set_status_filters(filter_args)
notifications = job.get_notifications(status=filter_args['status'])
- if job.template_type == 'letter':
- counts = render_template(
- 'partials/jobs/count-letters.html',
- job=job,
- )
- else:
- counts = render_template(
- 'partials/count.html',
- counts=_get_job_counts(job),
- status=filter_args['status'],
- notifications_deleted=(
- job.status == 'finished' and not notifications['notifications']
- ),
- )
+ counts = render_template(
+ 'partials/count.html',
+ counts=_get_job_counts(job),
+ status=filter_args['status'],
+ notifications_deleted=(
+ job.status == 'finished' and not notifications['notifications']
+ ),
+ )
service_data_retention_days = current_service.get_days_of_retention(job.template_type)
return {
diff --git a/app/templates/partials/jobs/count-letters.html b/app/templates/partials/jobs/count-letters.html
deleted file mode 100644
index 1e83b8f5a..000000000
--- a/app/templates/partials/jobs/count-letters.html
+++ /dev/null
@@ -1,22 +0,0 @@
-{% from 'components/big-number.html' import big_number %}
-
-
-
-
- {{ big_number(
- job.notification_count,
- job.notification_count|message_count_label('letter', suffix='')|capitalize,
- smaller=True
- )}}
-
-
-
-
- {{ big_number(
- job.letter_timings.earliest_delivery|string|format_date_short,
- 'Estimated delivery date',
- smaller=True
- )}}
-
-
-
diff --git a/app/templates/views/service-settings/letter-preview.html b/app/templates/views/service-settings/letter-preview.html
deleted file mode 100644
index 526b71065..000000000
--- a/app/templates/views/service-settings/letter-preview.html
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
- Letter preview
-
-
-
-
-
-
- {{ template }}
-
-
-
diff --git a/paas-failwhale/static_503/stylesheets/main.css b/paas-failwhale/static_503/stylesheets/main.css
index 1884fb794..3afa3ac5b 100644
--- a/paas-failwhale/static_503/stylesheets/main.css
+++ b/paas-failwhale/static_503/stylesheets/main.css
@@ -8467,81 +8467,6 @@ ol ol .sub-navigation__item {
}
}
-.letter {
- padding: 141.42136% 0 0 0;
- margin: 0 0 30px 0;
- position: relative;
- background: #dee0e2
-}
-
-.letter:before {
- position: absolute;
- top: 10%;
- left: 50%;
- margin-left: -0.5em;
- font-size: 96px;
- color: #fff;
- overflow: hidden;
- display: block;
- vertical-align: bottom;
- animation: ellipsis steps(4, end) 1.3s infinite;
- content: "\2026";
- width: 0px
-}
-
-.letter:after {
- content: "";
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- box-shadow: inset 0 0 0 1px #bfc1c3
-}
-
-.letter-postage {
- position: absolute;
- top: 0;
- right: 0;
- z-index: 10;
- width: 147.45253px;
- height: 124px;
- margin: 0;
- background-color: #9a9481;
- background-size: auto 124px;
- background-position: right 0;
- background-repeat: no-repeat;
- background-origin: border-box;
- text-indent: -1000em;
- border-bottom: 1px solid #bfc1c3;
- border-left: 1px solid #bfc1c3;
- box-shadow: 0 2px 0 0 rgba(191, 193, 195, 0.2)
-}
-
-.letter-postage-first {
- background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDIxLjEuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAyNzcuMyAyMzMuMiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMjc3LjMgMjMzLjI7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHN0eWxlIHR5cGU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MjMzLjg5KSI+Cgk8c3RvcCAgb2Zmc2V0PSIwIiBzdHlsZT0ic3RvcC1jb2xvcjojRkZGRkZGIi8+Cgk8c3RvcCAgb2Zmc2V0PSIxIiBzdHlsZT0ic3RvcC1jb2xvcjojMDAwMDAwIi8+CjwvbGluZWFyR3JhZGllbnQ+CjxwYXRoIGNsYXNzPSJzdDQiIGQ9Ik0xOTkuMywxNjUuOWgtNDMuOWMwLjItOSwyLjItMTcuMyw1LjgtMjQuOGMwLjctMS42LDEuNi0zLjMsMi42LTVMNjIsNTAuNXYxMjZoMTQ5LjlMMTk5LjMsMTY1Ljl6Ii8+Cjwvc3ZnPgo=)
-}
-
-.letter-sent .letter-postage:hover {
- background-color: transparent;
- border-color: transparent;
- box-shadow: none;
- background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDIxLjEuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAyNzcuMyAyMzMuMiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMjc3LjMgMjMzLjI7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4KCS5zdDB7ZmlsbDp1cmwoI1NWR0lEXzFfKTtmaWxsLW9wYWNpdHk6NC4wMDAwMDBlLTAyO30KCS5zdDF7ZmlsbDojNzI2NjUwO30KCS5zdDJ7ZmlsbDojQj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zA3O3N0b3Atb3BhY2l0eTowLjIyODEiLz4KCTxzdG9wICBvZmZzZXQ9IjAuNTEyNCIgc3R5bGU9InN0b3AtY29sb3I6IzAwMDAwMDtzdG9wLW9wYWNpdHk6MC4yNSIvPgoJPHN0b3AgIG9mZnNldD0iMC41Mzg4IiBzdHlsZT0ic3RvcC1jb2xvcjojMDAwMDAwO3N0b3Atb3BhY2l0eTowIi8+CjwvbGluZWFyR3JhZGllbnQ+CjxyZWN0IHg9IjIiIHk9Ii0zIiBjbGFzcz0ic3QwIiB3aWR0aD0iMjc3LjMiIGhlaWdodD0iMjMzLjIiLz4KPHBvbHlnb24gY2xhc3M9InN0MSIgcG9pbnRzPSIwLDAgMjc3LjMsMCAyNzcuMywyMzMuMiAyNzIsNi45ICIvPgo8cG9seWdvbiBjbGFzcz0ic3QyIiBwb2ludHM9IjIuNSwtMSAyNzkuOCwtMSAyNzkuOCwyMzIuMiAyNzQuNSw1LjkgIi8+Cjwvc3ZnPgo=)
-}
-
-.letter img {
- display: block;
- width: 100%;
- background: #fff;
- position: absolute;
- top: 0;
- left: 0
-}
-
input[type="search"] {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py
index fdcd862c4..f7f89e53e 100644
--- a/tests/app/main/views/test_notifications.py
+++ b/tests/app/main/views/test_notifications.py
@@ -207,7 +207,7 @@ def test_notification_page_doesnt_link_to_template_in_tour(
expected_message,
):
- with freeze_time('2012-01-01 01:01'):
+ with freeze_time('2012-01-01 06:01'):
notification = create_notification()
mocker.patch('app.notification_api_client.get_notification', return_value=notification)
@@ -225,262 +225,6 @@ def test_notification_page_doesnt_link_to_template_in_tour(
assert len(page.select('main p:nth-of-type(1) a')) == 0
-@freeze_time("2016-01-01 01:01")
-def test_notification_page_shows_page_for_letter_notification(
- client_request,
- mocker,
- fake_uuid,
-):
-
- count_of_pages = 3
-
- notification = create_notification(notification_status='created', template_type='letter', postage='second')
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
-
- mock_page_count = mocker.patch(
- 'app.main.views.notifications.get_page_count_for_letter',
- return_value=count_of_pages
- )
-
- 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) == (
- "‘sample template’ was sent by Test User today at 1:01am"
- )
- assert normalize_spaces(page.select('main p:nth-of-type(2)')[0].text) == (
- 'Printing starts today at 5:30pm'
- )
- assert normalize_spaces(page.select('main p:nth-of-type(3)')[0].text) == (
- 'Estimated delivery date: Wednesday 6 January'
- )
- assert len(page.select('.letter-postage')) == 1
- assert normalize_spaces(page.select_one('.letter-postage').text) == (
- 'Postage: second class'
- )
- assert page.select_one('.letter-postage')['class'] == [
- 'letter-postage', 'letter-postage-second'
- ]
- assert page.select('p.notification-status') == []
-
- letter_images = page.select('main img')
-
- assert len(letter_images) == count_of_pages
- for index in range(count_of_pages):
- assert page.select('img')[index]['src'].endswith(
- '.png?page={}'.format(index + 1)
- )
-
- assert len(mock_page_count.call_args_list) == 1
- assert mock_page_count.call_args_list[0][0][0]['name'] == 'sample template'
- 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.get_letter_file_data',
- 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', (
- (
- True,
- 'Provided as PDF today at 1:01am',
- 'This letter passed our checks, but we will not print it because you used a test key.',
- 'Postage: second class'
- ),
- (
- False,
- '‘sample template’ was sent today at 1:01am',
- 'We will not print this letter because you used a test key.',
- 'Postage: second class',
- ),
-))
-def test_notification_page_shows_page_for_letter_sent_with_test_key(
- client_request,
- mocker,
- fake_uuid,
- is_precompiled_letter,
- expected_p1,
- expected_p2,
- expected_postage,
-):
-
- if is_precompiled_letter:
- mocker.patch(
- 'app.main.views.notifications.get_letter_file_data',
- 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=is_precompiled_letter,
- postage='second',
- key_type='test',
- sent_one_off=False,
- )
- 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) == (
- expected_p1
- )
- assert normalize_spaces(page.select('main p:nth-of-type(2)')[0].text) == (
- expected_p2
- )
- assert normalize_spaces(
- page.select_one('.letter-postage').text
- ) == expected_postage
- assert page.select('p.notification-status') == []
-
-
-def test_notification_page_shows_validation_failed_precompiled_letter(
- client_request,
- mocker,
- fake_uuid,
-):
- notification = create_notification(template_type='letter',
- notification_status='validation-failed',
- is_precompiled_letter=True
- )
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
- metadata = {"page_count": "1", "status": "validation-failed",
- "invalid_pages": "[1]",
- "message": "content-outside-printable-area"}
- mocker.patch('app.main.views.notifications.get_letter_file_data',
- return_value=("some letter content", metadata))
- mocker.patch(
- 'app.main.views.notifications.get_page_count_for_letter',
- return_value=1,
- )
-
- page = client_request.get(
- 'main.view_notification',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- )
-
- error_message = page.find('p', class_='notification-status-cancelled').text
- assert normalize_spaces(error_message) == (
- 'Validation failed because content is outside the printable area on page 1.'
- 'Files must meet our letter specification.'
- )
-
- assert not page.select('p.notification-status')
-
- assert page.select_one('main img')['src'].endswith('.png?page=1')
- assert not page.select('.letter-postage')
-
-
-@pytest.mark.parametrize('notification_status, expected_message', (
- (
- 'permanent-failure',
- 'Permanent failure – The provider cannot print the letter. Your letter will not be dispatched.',
- ),
- (
- 'cancelled',
- 'Cancelled 1 January at 1:02am',
- ),
- (
- 'technical-failure',
- 'Technical failure – Notify will resend once the team have fixed the problem',
- ),
-))
-@freeze_time("2016-01-01 01:01")
-def test_notification_page_shows_cancelled_or_failed_letter(
- client_request,
- mocker,
- fake_uuid,
- notification_status,
- expected_message,
-):
- notification = create_notification(template_type='letter', notification_status=notification_status)
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
- mocker.patch(
- 'app.main.views.notifications.get_page_count_for_letter',
- return_value=1,
- )
-
- page = client_request.get(
- 'main.view_notification',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- )
-
- assert normalize_spaces(page.select('main p')[0].text) == (
- "‘sample template’ was sent by Test User today at 1:01am"
- )
- assert normalize_spaces(page.select('main p')[1].text) == (
- expected_message
- )
- assert not page.select('p.notification-status')
-
- assert page.select_one('main img')['src'].endswith('.png?page=1')
-
-
@pytest.mark.parametrize('notification_type', ['email', 'sms'])
@freeze_time('2016-01-01 15:00')
def test_notification_page_does_not_show_cancel_link_for_sms_or_email_notifications(
@@ -501,266 +245,6 @@ def test_notification_page_does_not_show_cancel_link_for_sms_or_email_notificati
assert 'Cancel sending this letter' not in normalize_spaces(page.text)
-@freeze_time('2016-01-01 15:00')
-def test_notification_page_shows_cancel_link_for_letter_which_can_be_cancelled(
- client_request,
- mocker,
- fake_uuid,
-):
- notification = create_notification(template_type='letter', notification_status='created')
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
-
- mocker.patch(
- 'app.main.views.notifications.get_page_count_for_letter',
- return_value=1
- )
-
- page = client_request.get(
- 'main.view_notification',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- )
-
- assert 'Cancel sending this letter' in normalize_spaces(page.text)
-
-
-@freeze_time('2016-01-01 15:00')
-def test_notification_page_does_not_show_cancel_link_for_letter_which_cannot_be_cancelled(
- client_request,
- mocker,
- fake_uuid,
-):
- notification = create_notification(template_type='letter')
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
-
- mocker.patch(
- 'app.main.views.notifications.get_page_count_for_letter',
- return_value=1
- )
-
- page = client_request.get(
- 'main.view_notification',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- )
-
- assert 'Cancel sending this letter' not in normalize_spaces(page.text)
-
-
-@pytest.mark.parametrize('postage, expected_postage_text, expected_class_value, expected_delivery', (
- (
- 'first',
- 'Postage: first class',
- 'letter-postage-first',
- 'Estimated delivery date: Tuesday 5 January',
- ),
- (
- 'europe',
- 'Postage: international',
- 'letter-postage-international',
- 'Estimated delivery date: Friday 8 January',
- ),
- (
- 'rest-of-world',
- 'Postage: international',
- 'letter-postage-international',
- 'Estimated delivery date: Monday 11 January',
- ),
-))
-@freeze_time("2016-01-01 18:00")
-def test_notification_page_shows_page_for_other_postage_classes(
- client_request,
- mocker,
- fake_uuid,
- postage,
- expected_postage_text,
- expected_class_value,
- expected_delivery,
-):
- notification = create_notification(
- notification_status='pending-virus-check',
- template_type='letter',
- postage=postage,
- )
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
- 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) == 'Printing starts tomorrow at 5:30pm'
- assert normalize_spaces(page.select('main p:nth-of-type(3)')[0].text) == (
- expected_delivery
- )
- assert normalize_spaces(page.select_one('.letter-postage').text) == (
- expected_postage_text
- )
- assert page.select_one('.letter-postage')['class'] == [
- 'letter-postage', expected_class_value
- ]
-
-
-@pytest.mark.parametrize('filetype', [
- 'pdf', 'png'
-])
-@pytest.mark.parametrize('user', [
- create_active_user_with_permissions(),
- create_active_caseworking_user(),
-])
-def test_should_show_image_of_letter_notification(
- client_request,
- fake_uuid,
- mocker,
- filetype,
- user,
-):
- mocker.patch('app.user_api_client.get_user', return_value=user)
-
- notification = create_notification(template_type='letter')
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
-
- mocker.patch(
- 'app.main.views.notifications.notification_api_client.get_notification_letter_preview',
- return_value={
- 'content': base64.b64encode(b'foo').decode('utf-8')
- }
- )
-
- response = client_request.get_response(
- 'main.view_letter_notification_as_preview',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- filetype=filetype
- )
-
- assert response.get_data(as_text=True) == 'foo'
-
-
-def test_should_show_image_of_letter_notification_that_failed_validation(
- client_request,
- fake_uuid,
- mocker
-):
- notification = create_notification(template_type='letter', notification_status='validation-failed')
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
-
- metadata = {
- 'message': 'content-outside-printable-area',
- 'invalid_pages': '[1]',
- 'page_count': '1'
- }
- mocker.patch(
- 'app.main.views.notifications.notification_api_client.get_notification_letter_preview',
- return_value={
- 'content': base64.b64encode(b'foo').decode('utf-8'),
- 'metadata': metadata
- }
- )
-
- response = client_request.get_response(
- 'main.view_letter_notification_as_preview',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- filetype='png',
- with_metadata=True,
- )
-
- assert response.get_data(as_text=True) == 'foo', metadata
-
-
-def test_should_show_image_of_templated_letter_notification_that_failed_validation_because_letter_is_too_long(
- client_request,
- mocker,
- fake_uuid,
-):
- notification = create_notification(
- notification_status='validation-failed',
- template_type='letter')
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
- mocker.patch('app.main.views.notifications.get_page_count_for_letter', return_value=11)
-
- page = client_request.get(
- 'main.view_notification',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- )
-
- error_message = page.find('p', class_='notification-status-cancelled').text
- assert normalize_spaces(error_message) == \
- "Validation failed because this letter is 11 pages long.Letters must be 10 pages or "\
- "less (5 double-sided sheets of paper)."
-
-
-def test_should_show_preview_error_image_letter_notification_on_preview_error(
- client_request,
- fake_uuid,
- mocker,
-):
- notification = create_notification(template_type='letter')
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
-
- mocker.patch(
- 'app.main.views.notifications.notification_api_client.get_notification_letter_preview',
- side_effect=APIError
- )
-
- mocker.patch("builtins.open", mock_open(read_data=b"preview error image"))
-
- response = client_request.get_response(
- 'main.view_letter_notification_as_preview',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- filetype='png',
- )
-
- assert response.get_data(as_text=True) == 'preview error image'
-
-
-def test_notification_page_shows_error_message_if_precompiled_letter_cannot_be_opened(
- client_request,
- mocker,
- fake_uuid,
-):
- notification = create_notification(
- notification_status='validation-failed',
- template_type='letter',
- is_precompiled_letter=True)
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
- mocker.patch(
- 'app.main.views.notifications.get_letter_file_data',
- side_effect=PdfReadError()
- )
- mocker.patch(
- 'app.main.views.notifications.pdf_page_count',
- side_effect=PdfReadError()
- )
- page = client_request.get(
- 'main.view_notification',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- )
-
- error_message = page.find('p', class_='notification-status-cancelled').text
- assert normalize_spaces(error_message) == \
- "Validation failed – There’s a problem with your letter. Notify cannot read this PDF."
-
-
-def test_should_404_for_unknown_extension(
- client_request,
- fake_uuid,
-):
- client_request.get(
- 'main.view_letter_notification_as_preview',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- filetype='docx',
- _expected_status=404,
- )
-
-
@pytest.mark.parametrize('service_permissions, template_type, link_expected', [
([], '', False),
(['inbound_sms'], 'email', False),
@@ -808,120 +292,6 @@ def test_notification_page_has_link_to_send_another_for_sms(
assert conversation_link not in str(page.select_one('main'))
-@pytest.mark.parametrize('template_type, expected_link', [
- ('email', lambda notification_id: None),
- ('sms', lambda notification_id: None),
- ('letter', partial(
- url_for,
- 'main.view_letter_notification_as_preview',
- service_id=SERVICE_ONE_ID,
- filetype='pdf'
- )),
-])
-def test_notification_page_has_link_to_download_letter(
- client_request,
- mocker,
- fake_uuid,
- service_one,
- template_type,
- expected_link,
-):
- notification = create_notification(template_type=template_type)
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
- mocker.patch(
- 'app.main.views.notifications.get_page_count_for_letter',
- return_value=1
- )
-
- page = client_request.get(
- 'main.view_notification',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- )
-
- try:
- download_link = page.select_one('a[download]')['href']
- except TypeError:
- download_link = None
-
- assert download_link == expected_link(notification_id=fake_uuid)
-
-
-@pytest.mark.parametrize('is_precompiled_letter, has_template_link', [
- (True, False),
- (False, True),
-])
-def test_notification_page_has_expected_template_link_for_letter(
- client_request,
- mocker,
- fake_uuid,
- service_one,
- is_precompiled_letter,
- has_template_link
-):
-
- if is_precompiled_letter:
- mocker.patch(
- 'app.main.views.notifications.get_letter_file_data',
- side_effect=[(b'foo', {"message": "", "invalid_pages": "[]", "page_count": "1"}), b'foo']
- )
-
- mocker.patch(
- 'app.main.views.notifications.pdf_page_count',
- return_value=1
- )
-
- notification = create_notification(template_type='letter', is_precompiled_letter=is_precompiled_letter)
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
- mocker.patch(
- 'app.main.views.notifications.get_page_count_for_letter',
- return_value=1
- )
-
- page = client_request.get(
- 'main.view_notification',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- )
-
- link = page.select_one('main > p:nth-of-type(1) > a')
-
- if has_template_link:
- assert link
- else:
- assert link is None
-
-
-def test_should_show_image_of_precompiled_letter_notification(
- client_request,
- fake_uuid,
- mocker,
-):
- notification = create_notification(template_type='letter', is_precompiled_letter=True)
- mocker.patch('app.notification_api_client.get_notification', return_value=notification)
- mock_pdf_page_count = mocker.patch(
- 'app.main.views.notifications.pdf_page_count',
- return_value=1
- )
-
- mocker.patch(
- 'app.main.views.notifications.notification_api_client.get_notification_letter_preview',
- return_value={
- 'content': base64.b64encode(b'foo').decode('utf-8')
- }
- )
-
- response = client_request.get_response(
- 'main.view_letter_notification_as_preview',
- service_id=SERVICE_ONE_ID,
- notification_id=fake_uuid,
- filetype="png",
- )
-
- assert response.get_data(as_text=True) == 'foo'
- assert mock_pdf_page_count.called_once()
-
-
@pytest.mark.parametrize('notification_type', ['sms', 'email'])
def test_should_show_reply_to_from_notification(
mocker,