mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 12:59:48 -04:00
@@ -139,10 +139,17 @@ def send_message_to_self(service_id, template_id):
|
|||||||
[first_column_heading[template.template_type]] +
|
[first_column_heading[template.template_type]] +
|
||||||
list(template.placeholders)
|
list(template.placeholders)
|
||||||
)
|
)
|
||||||
writer.writerow(
|
if template.template_type == 'sms':
|
||||||
[current_user.mobile_number] +
|
writer.writerow(
|
||||||
["test {}".format(header) for header in template.placeholders]
|
[current_user.mobile_number] +
|
||||||
)
|
["test {}".format(header) for header in template.placeholders]
|
||||||
|
)
|
||||||
|
if template.template_type == 'email':
|
||||||
|
writer.writerow(
|
||||||
|
[current_user.email_address] +
|
||||||
|
["test {}".format(header) for header in template.placeholders]
|
||||||
|
)
|
||||||
|
|
||||||
filedata = {
|
filedata = {
|
||||||
'file_name': 'Test run',
|
'file_name': 'Test run',
|
||||||
'data': output.getvalue().splitlines()
|
'data': output.getvalue().splitlines()
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
{% if upload_result.valid %}
|
{% if upload_result.valid %}
|
||||||
<form method="post" enctype="multipart/form-data">
|
<form method="post" enctype="multipart/form-data">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||||
<input type="submit" class="button" value="{{ "Send {} text message{}".format(upload_result.rows|count, '' if upload_result.rows|count == 1 else 's') }}" />
|
<input type="submit" class="button" value="{{ "Send {} message{}".format(upload_result.rows|count, '' if upload_result.rows|count == 1 else 's') }}" />
|
||||||
<a href="{{url_for('.send_messages', service_id=service_id, template_id=template.id)}}" class="page-footer-back-link">Back</a>
|
<a href="{{url_for('.send_messages', service_id=service_id, template_id=template.id)}}" class="page-footer-back-link">Back</a>
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
@@ -144,6 +144,30 @@ def test_send_test_message_to_self(
|
|||||||
mock_s3_upload.assert_called_with(ANY, '12345', expected_data, 'eu-west-1')
|
mock_s3_upload.assert_called_with(ANY, '12345', expected_data, 'eu-west-1')
|
||||||
|
|
||||||
|
|
||||||
|
def test_send_test_message_to_self(
|
||||||
|
app_,
|
||||||
|
mocker,
|
||||||
|
api_user_active,
|
||||||
|
mock_login,
|
||||||
|
mock_get_service,
|
||||||
|
mock_get_service_email_template,
|
||||||
|
mock_s3_upload
|
||||||
|
):
|
||||||
|
|
||||||
|
expected_data = {'data': ['email address', 'test@user.gov.uk'], 'file_name': 'Test run'}
|
||||||
|
mocker.patch('app.main.views.send.s3download', return_value='email address\r\ntest@user.gov.uk')
|
||||||
|
|
||||||
|
with app_.test_request_context():
|
||||||
|
with app_.test_client() as client:
|
||||||
|
client.login(api_user_active)
|
||||||
|
response = client.get(
|
||||||
|
url_for('main.send_message_to_self', service_id=12345, template_id=54321),
|
||||||
|
follow_redirects=True
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
mock_s3_upload.assert_called_with(ANY, '12345', expected_data, 'eu-west-1')
|
||||||
|
|
||||||
|
|
||||||
def test_download_example_csv(
|
def test_download_example_csv(
|
||||||
app_,
|
app_,
|
||||||
mocker,
|
mocker,
|
||||||
|
|||||||
@@ -141,6 +141,17 @@ def mock_get_service_template(mocker):
|
|||||||
'app.notifications_api_client.get_service_template', side_effect=_create)
|
'app.notifications_api_client.get_service_template', side_effect=_create)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='function')
|
||||||
|
def mock_get_service_email_template(mocker):
|
||||||
|
def _create(service_id, template_id):
|
||||||
|
template = template_json(
|
||||||
|
template_id, "Two week reminder", "email", "Your vehicle tax is about to expire", service_id)
|
||||||
|
return {'data': template}
|
||||||
|
|
||||||
|
return mocker.patch(
|
||||||
|
'app.notifications_api_client.get_service_template', side_effect=_create)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def mock_create_service_template(mocker):
|
def mock_create_service_template(mocker):
|
||||||
def _create(name, type_, content, service):
|
def _create(name, type_, content, service):
|
||||||
|
|||||||
Reference in New Issue
Block a user