From 5bc752a826507fac1d6cff3880e11e574a5c9b8f Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Fri, 22 Sep 2023 10:05:50 -0700 Subject: [PATCH] fix tests --- app/utils/csv.py | 5 ++++- tests/__init__.py | 2 +- tests/app/utils/test_csv.py | 21 ++++++++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/utils/csv.py b/app/utils/csv.py index 8f63eb4d5..a03417013 100644 --- a/app/utils/csv.py +++ b/app/utils/csv.py @@ -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"], diff --git a/tests/__init__.py b/tests/__init__.py index 7c522f435..bf6527147 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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) ], diff --git a/tests/app/utils/test_csv.py b/tests/app/utils/test_csv.py index 55ea638d9..35d48c233 100644 --- a/tests/app/utils/test_csv.py +++ b/tests/app/utils/test_csv.py @@ -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))