Skip to content

Commit

Permalink
Merge pull request #905 from GSA/notify-api-522
Browse files Browse the repository at this point in the history
Add carrier to downloadable reports
  • Loading branch information
ccostino authored Nov 3, 2023
2 parents 9398bab + 6e19fab commit 191700f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
20 changes: 18 additions & 2 deletions app/utils/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 = [
Expand All @@ -85,6 +95,8 @@ def generate_notifications_csv(**kwargs):
"Type",
"Sent by",
"Job",
"Carrier",
"Carrier Response",
"Status",
"Time",
]
Expand All @@ -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 = (
[
Expand All @@ -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"],
]
Expand All @@ -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"],
]
Expand Down
24 changes: 20 additions & 4 deletions tests/app/utils/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -82,15 +86,15 @@ def get_notifications_csv_mock(
(
None,
[
"Recipient,Template,Type,Sent by,Job,Status,Time\n",
"[email protected],foo,sms,,,Delivered,1943-04-19 12:00:00\r\n",
"Recipient,Template,Type,Sent by,Job,Carrier,Carrier Response,Status,Time\n",
"[email protected],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",
"[email protected],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",
"[email protected],foo,sms,Anne Example,,ATT Mobility,Did not like it,Delivered,1943-04-19 12:00:00\r\n",
],
),
],
Expand Down Expand Up @@ -128,6 +132,8 @@ def test_generate_notifications_csv_without_job(
"Type",
"Sent by",
"Job",
"Carrier",
"Carrier Response",
"Status",
"Time",
],
Expand All @@ -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",
],
Expand All @@ -157,6 +165,8 @@ def test_generate_notifications_csv_without_job(
"Type",
"Sent by",
"Job",
"Carrier",
"Carrier Response",
"Status",
"Time",
],
Expand All @@ -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",
],
Expand All @@ -189,6 +201,8 @@ def test_generate_notifications_csv_without_job(
"Type",
"Sent by",
"Job",
"Carrier",
"Carrier Response",
"Status",
"Time",
],
Expand All @@ -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",
],
Expand Down

0 comments on commit 191700f

Please sign in to comment.