From 0b905249a75444a80b5b1216801f7ff481e88c25 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 4 Apr 2018 17:10:22 +0100 Subject: [PATCH] Make send test letter preview use template ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The check page expects template ID to be passed through in the URL not the session now. The send test letter page wasn’t changed. This commit changes it, and adds a test to make sure this path is covered. --- app/main/views/send.py | 2 +- tests/app/main/views/test_send.py | 43 ++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index 08af846c1..18b1e7183 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -717,7 +717,7 @@ def make_and_upload_csv_file(service_id, template): '.check_messages', upload_id=upload_id, service_id=service_id, - template_type=template.template_type, + template_id=template.id, from_test=True, help=2 if get_help_argument() else 0 )) diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 473bdf420..d3a13c27c 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -1170,6 +1170,46 @@ def test_send_test_letter_clears_previous_page_cache( assert session['send_test_letter_page_count'] is None +def test_send_test_letter_redirects_to_right_url( + logged_in_platform_admin_client, + fake_uuid, + mock_get_service_letter_template, + mock_s3_upload, + mock_get_users_by_service, + mock_get_detailed_service_for_today, + mocker, +): + + with logged_in_platform_admin_client.session_transaction() as session: + session['send_test_letter_page_count'] = 1 + session['recipient'] = '' + session['placeholders'] = { + 'address line 1': 'foo', + 'address line 2': 'bar', + 'address line 3': '', + 'address line 4': '', + 'address line 5': '', + 'address line 6': '', + 'postcode': 'SW1 1AA', + } + + response = logged_in_platform_admin_client.get(url_for( + 'main.send_one_off_step', + service_id=SERVICE_ONE_ID, + template_id=fake_uuid, + step_index=7, # letter template has 7 placeholders – we’re at the end + )) + + assert response.status_code == 302 + assert response.location.startswith(url_for( + 'main.check_messages', + service_id=SERVICE_ONE_ID, + template_id=fake_uuid, + upload_id=fake_uuid, + _external=True, + )) + + def test_send_test_populates_field_from_session( logged_in_client, mocker, @@ -1622,7 +1662,6 @@ def test_can_start_letters_job( with logged_in_platform_admin_client.session_transaction() as session: session['file_uploads'] = { fake_uuid: { - 'original_file_name': 'example.csv', 'template_id': fake_uuid, 'notification_count': 123, 'valid': True @@ -1686,7 +1725,6 @@ def test_should_show_preview_letter_message( with logged_in_platform_admin_client.session_transaction() as session: session['file_uploads'] = { fake_uuid: { - 'original_file_name': 'example.csv', 'template_id': fake_uuid, 'notification_count': 1, 'valid': True @@ -2740,7 +2778,6 @@ def test_sms_sender_is_previewed( session['placeholders'] = {} session['file_uploads'] = { fake_uuid: { - 'original_file_name': 'example.csv', 'template_id': fake_uuid, 'notification_count': 1, 'valid': True