Make send test letter preview use template ID

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.
This commit is contained in:
Chris Hill-Scott
2018-04-04 17:10:22 +01:00
parent b2722a0cd7
commit 0b905249a7
2 changed files with 41 additions and 4 deletions

View File

@@ -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 were 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