From c033a7c256c5041c8b2264366f02f45bd45b7c30 Mon Sep 17 00:00:00 2001 From: Julian Bez Date: Thu, 29 Feb 2024 10:12:24 +0000 Subject: [PATCH] fix(exports): Fix xlsx export extension (#20629) --- posthog/models/exported_asset.py | 2 +- posthog/tasks/exports/test/test_csv_exporter.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/posthog/models/exported_asset.py b/posthog/models/exported_asset.py index c56455527e923..ceebb2bc3db03 100644 --- a/posthog/models/exported_asset.py +++ b/posthog/models/exported_asset.py @@ -83,7 +83,7 @@ def has_content(self): @property def filename(self): - ext = self.export_format.split("/")[1] + ext = self.ExportFormat(self.export_format).name.lower() filename = "export" if self.export_context and self.export_context.get("filename"): diff --git a/posthog/tasks/exports/test/test_csv_exporter.py b/posthog/tasks/exports/test/test_csv_exporter.py index d0a05c2b4170b..e0de5e5ef720c 100644 --- a/posthog/tasks/exports/test/test_csv_exporter.py +++ b/posthog/tasks/exports/test/test_csv_exporter.py @@ -268,6 +268,7 @@ def test_csv_exporter_excel(self, mocked_object_storage_write: Any, mocked_uuidt with self.settings(OBJECT_STORAGE_ENABLED=True, OBJECT_STORAGE_EXPORTS_FOLDER="Test-Exports"): csv_exporter.export_tabular(exported_asset) + assert exported_asset.filename == "export.xlsx" assert exported_asset.content_location is None wb = load_workbook(filename=BytesIO(exported_asset.content))