mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 03:13:42 -05:00
Merge pull request #381 from alphagov/fix-csv-reupload
Fix re-uploading of CSV files
This commit is contained in:
@@ -252,6 +252,17 @@ def check_messages(service_id, template_type, upload_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/<template_type>/check/<upload_id>", methods=['POST'])
|
||||
@login_required
|
||||
@user_has_permissions('send_texts', 'send_emails', 'send_letters')
|
||||
def recheck_messages(service_id, template_type, upload_id):
|
||||
|
||||
if not session.get('upload_data'):
|
||||
return redirect(url_for('main.choose_template', service_id=service_id, template_type=template_type))
|
||||
|
||||
return send_messages(service_id, session['upload_data'].get('template_id'))
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/start-job/<upload_id>", methods=['POST'])
|
||||
@login_required
|
||||
@user_has_permissions('send_texts', 'send_emails', 'send_letters')
|
||||
|
||||
@@ -25,19 +25,26 @@ def test_upload_csvfile_with_errors_shows_check_page_with_errors(
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.post(
|
||||
initial_upload = client.post(
|
||||
url_for('main.send_messages', service_id=12345, template_id=54321),
|
||||
data={'file': (BytesIO(contents.encode('utf-8')), 'invalid.csv')},
|
||||
content_type='multipart/form-data',
|
||||
follow_redirects=True
|
||||
)
|
||||
assert response.status_code == 200
|
||||
content = response.get_data(as_text=True)
|
||||
assert 'There was a problem with invalid.csv' in content
|
||||
assert '+44 123' in content
|
||||
assert '+44 456' in content
|
||||
assert 'Not a UK mobile number' in content
|
||||
assert 'Re-upload your file' in content
|
||||
reupload = client.post(
|
||||
url_for('main.check_messages', service_id=12345, template_type='sms', upload_id='abc123'),
|
||||
data={'file': (BytesIO(contents.encode('utf-8')), 'invalid.csv')},
|
||||
content_type='multipart/form-data',
|
||||
follow_redirects=True
|
||||
)
|
||||
for response in [initial_upload, reupload]:
|
||||
assert response.status_code == 200
|
||||
content = response.get_data(as_text=True)
|
||||
assert 'There was a problem with invalid.csv' in content
|
||||
assert '+44 123' in content
|
||||
assert '+44 456' in content
|
||||
assert 'Not a UK mobile number' in content
|
||||
assert 'Re-upload your file' in content
|
||||
|
||||
|
||||
def test_send_test_sms_message_to_self(
|
||||
|
||||
Reference in New Issue
Block a user