diff --git a/app/utils.py b/app/utils.py index 47285924e..4d108fbb9 100644 --- a/app/utils.py +++ b/app/utils.py @@ -175,7 +175,7 @@ def generate_notifications_csv(**kwargs): notification['created_at'], notification['updated_at'] ] - yield ','.join(map(str, values)) + '\n' + yield Spreadsheet.from_rows([map(str, values)]).as_csv_data if notifications_resp['links'].get('next'): kwargs['page'] += 1 diff --git a/tests/app/test_utils.py b/tests/app/test_utils.py index 8c0959554..e1090ec48 100644 --- a/tests/app/test_utils.py +++ b/tests/app/test_utils.py @@ -145,6 +145,14 @@ def test_can_create_spreadsheet_from_dict_with_filename(): ['Row number', 'phone_number', 'a', 'b', 'c', 'Template', 'Type', 'Job', 'Status', 'Time'], ['1', '07700900123', '🐜', '🐝', '🦀', 'foo', 'sms', 'bar.csv', 'Delivered', 'Thursday 19 April at 12:00'], ), + ( + """ + "phone_number", "a", "b", "c" + "07700900123","🐜,🐜","🐝,🐝","🦀" + """, + ['Row number', 'phone_number', 'a', 'b', 'c', 'Template', 'Type', 'Job', 'Status', 'Time'], + ['1', '07700900123', '🐜,🐜', '🐝,🐝', '🦀', 'foo', 'sms', 'bar.csv', 'Delivered', 'Thursday 19 April at 12:00'], + ), ]) def test_generate_notifications_csv_returns_correct_csv_file( app_,