mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 08:28:15 -04:00
initial
This commit is contained in:
@@ -555,7 +555,7 @@
|
|||||||
"filename": "tests/app/main/views/test_register.py",
|
"filename": "tests/app/main/views/test_register.py",
|
||||||
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 200,
|
"line_number": 199,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -563,7 +563,7 @@
|
|||||||
"filename": "tests/app/main/views/test_register.py",
|
"filename": "tests/app/main/views/test_register.py",
|
||||||
"hashed_secret": "bb5b7caa27d005d38039e3797c3ddb9bcd22c3c8",
|
"hashed_secret": "bb5b7caa27d005d38039e3797c3ddb9bcd22c3c8",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 273,
|
"line_number": 272,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -684,5 +684,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"generated_at": "2025-01-13T20:16:58Z"
|
"generated_at": "2025-01-16T20:00:12Z"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ class CsvFileValidator:
|
|||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
def __call__(self, form, field):
|
def __call__(self, form, field):
|
||||||
|
if not Spreadsheet.approves_headers(field.data):
|
||||||
|
raise ValidationError(
|
||||||
|
f"{field.data.filename} does not have headers in row 1"
|
||||||
|
)
|
||||||
if not Spreadsheet.can_handle(field.data.filename):
|
if not Spreadsheet.can_handle(field.data.filename):
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
"{} is not a spreadsheet that Notify can read".format(
|
"{} is not a spreadsheet that Notify can read".format(
|
||||||
|
|||||||
@@ -32,11 +32,7 @@ def check_feature_flags():
|
|||||||
@main.route("/test/feature-flags")
|
@main.route("/test/feature-flags")
|
||||||
def test_feature_flags():
|
def test_feature_flags():
|
||||||
return jsonify(
|
return jsonify(
|
||||||
{
|
{"FEATURE_ABOUT_PAGE_ENABLED": current_app.config["FEATURE_ABOUT_PAGE_ENABLED"]}
|
||||||
"FEATURE_ABOUT_PAGE_ENABLED": current_app.config[
|
|
||||||
"FEATURE_ABOUT_PAGE_ENABLED"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -235,7 +231,6 @@ def contact():
|
|||||||
return render_template(
|
return render_template(
|
||||||
"views/contact.html",
|
"views/contact.html",
|
||||||
navigation_links=about_notify_nav(),
|
navigation_links=about_notify_nav(),
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -268,7 +263,6 @@ def join_notify():
|
|||||||
return render_template(
|
return render_template(
|
||||||
"views/join-notify.html",
|
"views/join-notify.html",
|
||||||
navigation_links=about_notify_nav(),
|
navigation_links=about_notify_nav(),
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ class Spreadsheet:
|
|||||||
self._csv_data = converted.getvalue()
|
self._csv_data = converted.getvalue()
|
||||||
return self._csv_data
|
return self._csv_data
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def approves_headers(cls, field_data):
|
||||||
|
raise Exception(f"Field data {field_data}")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def can_handle(cls, filename):
|
def can_handle(cls, filename):
|
||||||
return cls.get_extension(filename) in cls.ALLOWED_FILE_EXTENSIONS
|
return cls.get_extension(filename) in cls.ALLOWED_FILE_EXTENSIONS
|
||||||
|
|||||||
@@ -122,9 +122,7 @@ def test_static_pages(client_request, mock_get_organization_by_domain, view, moc
|
|||||||
session["user_id"] = None
|
session["user_id"] = None
|
||||||
request(
|
request(
|
||||||
_expected_status=302,
|
_expected_status=302,
|
||||||
_expected_redirect="/sign-in?next={}".format(
|
_expected_redirect="/sign-in?next={}".format(url_for("main.{}".format(view))),
|
||||||
url_for("main.{}".format(view))
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -144,9 +144,8 @@ def test_should_return_200_when_email_is_not_gov_uk(
|
|||||||
_expected_status=200,
|
_expected_status=200,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert (
|
assert "Enter a public sector email address." in normalize_spaces(
|
||||||
"Enter a public sector email address."
|
page.select_one(".usa-error-message").text
|
||||||
in normalize_spaces(page.select_one(".usa-error-message").text)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -898,6 +898,67 @@ def test_upload_csv_invalid_extension(
|
|||||||
assert "invalid.txt is not a spreadsheet that Notify can read" in page.text
|
assert "invalid.txt is not a spreadsheet that Notify can read" in page.text
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("file_contents", "expected_error"),
|
||||||
|
[
|
||||||
|
(
|
||||||
|
"""
|
||||||
|
|
||||||
|
phone number, name
|
||||||
|
+12028675109, example
|
||||||
|
+12028675109,
|
||||||
|
+12028675109, example
|
||||||
|
""",
|
||||||
|
(
|
||||||
|
"There’s a problem with example.csv "
|
||||||
|
"You need to put the column headers in row 1."
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_upload_csv_file_with_extra_blank_lines_is_flagged(
|
||||||
|
client_request,
|
||||||
|
mocker,
|
||||||
|
mock_get_service_template_with_placeholders,
|
||||||
|
mock_get_users_by_service,
|
||||||
|
mock_get_service_statistics,
|
||||||
|
mock_get_job_doesnt_exist,
|
||||||
|
mock_get_jobs,
|
||||||
|
service_one,
|
||||||
|
fake_uuid,
|
||||||
|
file_contents,
|
||||||
|
expected_error,
|
||||||
|
):
|
||||||
|
|
||||||
|
mocker.patch("app.main.views.send.set_metadata_on_csv_upload")
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
"app.main.views.send.get_csv_metadata",
|
||||||
|
return_value={"original_file_name": "example.csv"},
|
||||||
|
)
|
||||||
|
mocker.patch("app.main.views.send.s3upload", return_value=sample_uuid())
|
||||||
|
|
||||||
|
mocker.patch("app.main.views.send.s3download", return_value=file_contents)
|
||||||
|
|
||||||
|
page = client_request.post(
|
||||||
|
"main.send_messages",
|
||||||
|
service_id=service_one["id"],
|
||||||
|
template_id=fake_uuid,
|
||||||
|
_data={"file": (BytesIO("".encode("utf-8")), "example.csv")},
|
||||||
|
_follow_redirects=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
with client_request.session_transaction() as session:
|
||||||
|
assert "file_uploads" not in session
|
||||||
|
|
||||||
|
assert page.select_one("input[type=file]").has_attr("accept")
|
||||||
|
assert (
|
||||||
|
page.select_one("input[type=file]")["accept"]
|
||||||
|
== ".csv,.xlsx,.xls,.ods,.xlsm,.tsv"
|
||||||
|
)
|
||||||
|
assert normalize_spaces(page.select(".banner-dangerous")[0].text) == expected_error
|
||||||
|
|
||||||
|
|
||||||
def test_upload_csv_size_too_big(
|
def test_upload_csv_size_too_big(
|
||||||
client_request,
|
client_request,
|
||||||
mock_login,
|
mock_login,
|
||||||
|
|||||||
Reference in New Issue
Block a user