From 4f009cfd9bb59bf9c018b621ddb0865526c3d164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Riku=20Kestila=CC=88?= Date: Fri, 17 Nov 2023 10:52:26 +0200 Subject: [PATCH] feat: add BOM to batch zip csv --- backend/benefit/applications/services/csv_export_base.py | 4 ++-- backend/benefit/applications/tests/test_talpa_integration.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/benefit/applications/services/csv_export_base.py b/backend/benefit/applications/services/csv_export_base.py index 6db485c6c3..93ae66abd5 100644 --- a/backend/benefit/applications/services/csv_export_base.py +++ b/backend/benefit/applications/services/csv_export_base.py @@ -75,7 +75,7 @@ def write_csv_file(self, path) -> None: def get_csv_string(self, remove_quotes: bool = False) -> str: return "".join( # Lines end with '\r\n' already so no need to add newlines here - self.get_csv_string_lines_generator(remove_quotes=remove_quotes) + self.get_csv_string_lines_generator(remove_quotes=remove_quotes, add_bom=True) ) def get_csv_cell_list_lines_generator( @@ -138,7 +138,7 @@ def get_csv_string_lines_generator( for line in self.get_csv_cell_list_lines_generator(): line_length_set.add(len(line)) - assert len(line_length_set) == 1, "Each CSV line must have same colum count" + assert len(line_length_set) == 1, "Each CSV line must have same column count" csv_writer.writerow(line) yield io.getvalue() # Reset StringIO object diff --git a/backend/benefit/applications/tests/test_talpa_integration.py b/backend/benefit/applications/tests/test_talpa_integration.py index 1e1a596baa..097a6b46b2 100644 --- a/backend/benefit/applications/tests/test_talpa_integration.py +++ b/backend/benefit/applications/tests/test_talpa_integration.py @@ -41,7 +41,7 @@ def test_talpa_csv_output(pruned_applications_csv_service_with_one_application): pruned_applications_csv_service_with_one_application.get_csv_string() ) # BOM at the beginning of the file - assert csv_lines[0][0] == '"Hakemusnumero"' + assert csv_lines[0][0] == '\ufeff"Hakemusnumero"' csv_columns = iter(pruned_applications_csv_service_with_one_application.CSV_COLUMNS) next(csv_columns, None) # Skip the first element