fix tests

This commit is contained in:
Kenneth Kehl
2023-09-22 10:05:50 -07:00
parent e3490691d3
commit 5bc752a826
3 changed files with 23 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
from flask import current_app
from notifications_utils.recipients import RecipientCSV
from app.models.spreadsheet import Spreadsheet
@@ -75,7 +76,7 @@ def generate_notifications_csv(**kwargs):
fieldnames = (
["Row number"]
+ original_column_headers
+ ["Template", "Type", "Job", "Status", "Time"]
+ ["Template", "Type", "Sent by", "Job", "Status", "Time"]
)
else:
fieldnames = [
@@ -95,6 +96,7 @@ def generate_notifications_csv(**kwargs):
**kwargs
)
for notification in notifications_resp["notifications"]:
current_app.logger.info(notification)
if kwargs.get("job_id"):
values = (
[
@@ -107,6 +109,7 @@ def generate_notifications_csv(**kwargs):
+ [
notification["template_name"],
notification["template_type"],
notification["created_by_name"],
notification["job_name"],
notification["status"],
notification["created_at"],

View File

@@ -517,7 +517,7 @@ def notification_json(
"notification_type": template_type,
"reply_to_text": reply_to_text,
"client_reference": client_reference,
"created_by_name": created_by_name,
"created_by_name": None,
}
for i in range(rows)
],

View File

@@ -19,8 +19,8 @@ def _get_notifications_csv(
rows=1,
with_links=False,
job_id=fake_uuid,
created_by_name=None,
created_by_email_address=None,
created_by_name="Fake Person",
created_by_email_address="FakePerson@fake.gov",
):
def _get(
service_id,
@@ -121,12 +121,22 @@ def test_generate_notifications_csv_without_job(
phone_number
2028675309
""",
["Row number", "phone_number", "Template", "Type", "Job", "Status", "Time"],
[
"Row number",
"phone_number",
"Template",
"Type",
"Sent by",
"Job",
"Status",
"Time",
],
[
"1",
"2028675309",
"foo",
"sms",
"Fake Person",
"bar.csv",
"Delivered",
"1943-04-19 12:00:00",
@@ -145,6 +155,7 @@ def test_generate_notifications_csv_without_job(
"c",
"Template",
"Type",
"Sent by",
"Job",
"Status",
"Time",
@@ -157,6 +168,7 @@ def test_generate_notifications_csv_without_job(
"🦀",
"foo",
"sms",
"Fake Person",
"bar.csv",
"Delivered",
"1943-04-19 12:00:00",
@@ -175,6 +187,7 @@ def test_generate_notifications_csv_without_job(
"c",
"Template",
"Type",
"Sent by",
"Job",
"Status",
"Time",
@@ -187,6 +200,7 @@ def test_generate_notifications_csv_without_job(
"🦀",
"foo",
"sms",
"Fake Person",
"bar.csv",
"Delivered",
"1943-04-19 12:00:00",
@@ -209,6 +223,7 @@ def test_generate_notifications_csv_returns_correct_csv_file(
csv_content = generate_notifications_csv(
service_id="1234", job_id=fake_uuid, template_type="sms"
)
csv_file = DictReader(StringIO("\n".join(csv_content)))
assert csv_file.fieldnames == expected_column_headers
assert next(csv_file) == dict(zip(expected_column_headers, expected_1st_row))