diff --git a/app/main/views/send.py b/app/main/views/send.py index 73c91ded2..2ef85dd24 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -250,8 +250,10 @@ def check_messages(service_id, template_type, upload_id): back_link = url_for( '.choose_template', service_id=service_id, template_type=template.template_type, **extra_args ) + choose_time_form = None else: back_link = url_for('.send_messages', service_id=service_id, template_id=template.id) + choose_time_form = ChooseTimeForm() with suppress(StopIteration): template.values = next(recipients.rows) @@ -276,7 +278,7 @@ def check_messages(service_id, template_type, upload_id): upload_id=upload_id, form=CsvUploadForm(), remaining_messages=remaining_messages, - choose_time_form=ChooseTimeForm(), + choose_time_form=choose_time_form, back_link=back_link, help=get_help_argument() ) diff --git a/app/templates/views/check.html b/app/templates/views/check.html index 998547874..4cb5e5e26 100644 --- a/app/templates/views/check.html +++ b/app/templates/views/check.html @@ -145,10 +145,12 @@
diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 3a6fa782a..abefc56fb 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -322,6 +322,41 @@ def test_upload_csvfile_with_valid_phone_shows_all_numbers( mock_get_detailed_service_for_today.assert_called_once_with(fake_uuid) +def test_test_message_can_only_be_sent_now( + app_, + mocker, + api_user_active, + mock_login, + mock_get_service, + mock_get_service_template, + mock_s3_download, + mock_has_permissions, + mock_get_users_by_service, + mock_get_detailed_service_for_today, + fake_uuid +): + + with app_.test_request_context(), app_.test_client() as client: + client.login(api_user_active) + with client.session_transaction() as session: + session['upload_data'] = { + 'original_file_name': 'Test message', + 'template_id': fake_uuid, + 'notification_count': 1, + 'valid': True + } + response = client.get(url_for( + 'main.check_messages', + service_id=fake_uuid, + upload_id=fake_uuid, + template_type='sms', + from_test=True + )) + + content = response.get_data(as_text=True) + assert 'name="scheduled_for"' not in content + + @pytest.mark.parametrize( 'when', [ '', '2016-08-25T13:04:21.767198'