From 6e19fab1d578bd038030dd776ed2f5e8c0c72daf Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Fri, 3 Nov 2023 10:38:38 -0700 Subject: [PATCH] more tests --- app/utils/csv.py | 20 ++++++++++++++++++-- tests/app/utils/test_csv.py | 24 ++++++++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/app/utils/csv.py b/app/utils/csv.py index a03417013f..37cc942380 100644 --- a/app/utils/csv.py +++ b/app/utils/csv.py @@ -63,6 +63,7 @@ def generate_notifications_csv(**kwargs): from app import notification_api_client from app.s3_client.s3_csv_client import s3download + current_app.logger.info("\n\n\n\nENTER generate_notifications_csv") if "page" not in kwargs: kwargs["page"] = 1 @@ -76,7 +77,16 @@ def generate_notifications_csv(**kwargs): fieldnames = ( ["Row number"] + original_column_headers - + ["Template", "Type", "Sent by", "Job", "Status", "Time"] + + [ + "Template", + "Type", + "Sent by", + "Job", + "Carrier", + "Carrier Response", + "Status", + "Time", + ] ) else: fieldnames = [ @@ -85,6 +95,8 @@ def generate_notifications_csv(**kwargs): "Type", "Sent by", "Job", + "Carrier", + "Carrier Response", "Status", "Time", ] @@ -96,7 +108,7 @@ def generate_notifications_csv(**kwargs): **kwargs ) for notification in notifications_resp["notifications"]: - current_app.logger.info(notification) + current_app.logger.info(f"\n\n{notification}") if kwargs.get("job_id"): values = ( [ @@ -111,6 +123,8 @@ def generate_notifications_csv(**kwargs): notification["template_type"], notification["created_by_name"], notification["job_name"], + notification["carrier"], + notification["provider_response"], notification["status"], notification["created_at"], ] @@ -122,6 +136,8 @@ def generate_notifications_csv(**kwargs): notification["template_type"], notification["created_by_name"] or "", notification["job_name"] or "", + notification["carrier"], + notification["provider_response"], notification["status"], notification["created_at"], ] diff --git a/tests/app/utils/test_csv.py b/tests/app/utils/test_csv.py index 545afd6ddb..f56fd25486 100644 --- a/tests/app/utils/test_csv.py +++ b/tests/app/utils/test_csv.py @@ -14,6 +14,8 @@ def _get_notifications_csv( template_name="foo", template_type="sms", job_name="bar.csv", + carrier="ATT Mobility", + provider_response="Did not like it", status="Delivered", created_at="1943-04-19 12:00:00", rows=1, @@ -47,6 +49,8 @@ def _get( "template_type": template_type, "template": {"name": template_name, "template_type": template_type}, "job_name": job_name, + "carrier": carrier, + "provider_response": provider_response, "status": status, "created_at": created_at, "updated_at": None, @@ -82,15 +86,15 @@ def get_notifications_csv_mock( ( None, [ - "Recipient,Template,Type,Sent by,Job,Status,Time\n", - "foo@bar.com,foo,sms,,,Delivered,1943-04-19 12:00:00\r\n", + "Recipient,Template,Type,Sent by,Job,Carrier,Carrier Response,Status,Time\n", + "foo@bar.com,foo,sms,,,ATT Mobility,Did not like it,Delivered,1943-04-19 12:00:00\r\n", ], ), ( "Anne Example", [ - "Recipient,Template,Type,Sent by,Job,Status,Time\n", - "foo@bar.com,foo,sms,Anne Example,,Delivered,1943-04-19 12:00:00\r\n", + "Recipient,Template,Type,Sent by,Job,Carrier,Carrier Response,Status,Time\n", + "foo@bar.com,foo,sms,Anne Example,,ATT Mobility,Did not like it,Delivered,1943-04-19 12:00:00\r\n", ], ), ], @@ -128,6 +132,8 @@ def test_generate_notifications_csv_without_job( "Type", "Sent by", "Job", + "Carrier", + "Carrier Response", "Status", "Time", ], @@ -138,6 +144,8 @@ def test_generate_notifications_csv_without_job( "sms", "Fake Person", "bar.csv", + "ATT Mobility", + "Did not like it", "Delivered", "1943-04-19 12:00:00", ], @@ -157,6 +165,8 @@ def test_generate_notifications_csv_without_job( "Type", "Sent by", "Job", + "Carrier", + "Carrier Response", "Status", "Time", ], @@ -170,6 +180,8 @@ def test_generate_notifications_csv_without_job( "sms", "Fake Person", "bar.csv", + "ATT Mobility", + "Did not like it", "Delivered", "1943-04-19 12:00:00", ], @@ -189,6 +201,8 @@ def test_generate_notifications_csv_without_job( "Type", "Sent by", "Job", + "Carrier", + "Carrier Response", "Status", "Time", ], @@ -202,6 +216,8 @@ def test_generate_notifications_csv_without_job( "sms", "Fake Person", "bar.csv", + "ATT Mobility", + "Did not like it", "Delivered", "1943-04-19 12:00:00", ],