mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 07:46:23 -04:00
Fix wrong error message if file is missing columns
Accidentally got broken here:
41fa158635 (diff-bff3df90be0231a1e33e033fc51ba7f7L78)
This commit changes it back to how it was before (but keeping the new macro for formatting the list).
This commit is contained in:
@@ -70,7 +70,7 @@
|
|||||||
) }}.
|
) }}.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
It doesn’t have {{ recipients.column_headers | formatted_list(
|
It doesn’t have {{ recipients.missing_column_headers | formatted_list(
|
||||||
conjunction='or',
|
conjunction='or',
|
||||||
prefix='a column called ',
|
prefix='a column called ',
|
||||||
prefix_plural='columns called '
|
prefix_plural='columns called '
|
||||||
|
|||||||
@@ -115,7 +115,32 @@ def test_upload_csvfile_with_errors_shows_check_page_with_errors(
|
|||||||
assert 'Re-upload your file' in content
|
assert 'Re-upload your file' in content
|
||||||
|
|
||||||
|
|
||||||
def test_upload_csvfile_with_no_recipient_column_shows_error(
|
@pytest.mark.parametrize('file_contents, expected_error,', [
|
||||||
|
(
|
||||||
|
"""
|
||||||
|
telephone,name
|
||||||
|
+447700900986
|
||||||
|
""",
|
||||||
|
(
|
||||||
|
'Your file needs to have a column called ‘phone number’ '
|
||||||
|
'Your file has columns called ‘telephone’ and ‘name’. '
|
||||||
|
'Skip to file contents'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"""
|
||||||
|
phone number
|
||||||
|
+447700900986
|
||||||
|
""",
|
||||||
|
(
|
||||||
|
'The columns in your file need to match the double brackets in your template '
|
||||||
|
'Your file has one column, called ‘phone number’. '
|
||||||
|
'It doesn’t have a column called ‘name’. '
|
||||||
|
'Skip to file contents'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
])
|
||||||
|
def test_upload_csvfile_with_missing_columns_shows_error(
|
||||||
logged_in_client,
|
logged_in_client,
|
||||||
mocker,
|
mocker,
|
||||||
mock_get_service_template_with_placeholders,
|
mock_get_service_template_with_placeholders,
|
||||||
@@ -124,15 +149,11 @@ def test_upload_csvfile_with_no_recipient_column_shows_error(
|
|||||||
mock_get_detailed_service_for_today,
|
mock_get_detailed_service_for_today,
|
||||||
service_one,
|
service_one,
|
||||||
fake_uuid,
|
fake_uuid,
|
||||||
|
file_contents,
|
||||||
|
expected_error,
|
||||||
):
|
):
|
||||||
|
|
||||||
mocker.patch(
|
mocker.patch('app.main.views.send.s3download', return_value=file_contents)
|
||||||
'app.main.views.send.s3download',
|
|
||||||
return_value="""
|
|
||||||
telephone,name
|
|
||||||
+447700900986
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
response = logged_in_client.post(
|
response = logged_in_client.post(
|
||||||
url_for('main.send_messages', service_id=service_one['id'], template_id=fake_uuid),
|
url_for('main.send_messages', service_id=service_one['id'], template_id=fake_uuid),
|
||||||
@@ -142,11 +163,7 @@ def test_upload_csvfile_with_no_recipient_column_shows_error(
|
|||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||||
assert ' '.join(page.select('.banner-dangerous')[0].text.split()) == (
|
assert ' '.join(page.select('.banner-dangerous')[0].text.split()) == expected_error
|
||||||
'Your file needs to have a column called ‘phone number’ '
|
|
||||||
'Your file has columns called ‘telephone’ and ‘name’. '
|
|
||||||
'Skip to file contents'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_upload_csv_invalid_extension(
|
def test_upload_csv_invalid_extension(
|
||||||
|
|||||||
Reference in New Issue
Block a user