From 8642d48e5ab4767668d512a2426b4d62f63a48d0 Mon Sep 17 00:00:00 2001 From: Kelvin Muchiri Date: Fri, 23 Aug 2024 16:59:10 +0300 Subject: [PATCH] fix failing tests --- onadata/apps/api/tests/viewsets/test_data_viewset.py | 5 ++++- onadata/libs/tests/utils/test_export_tools.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/onadata/apps/api/tests/viewsets/test_data_viewset.py b/onadata/apps/api/tests/viewsets/test_data_viewset.py index 41f45695d0..cf8982ed25 100644 --- a/onadata/apps/api/tests/viewsets/test_data_viewset.py +++ b/onadata/apps/api/tests/viewsets/test_data_viewset.py @@ -3782,7 +3782,10 @@ def test_data_retrieve_instance_osm_format(self): self._publish_xls_form_to_project(xlsform_path=xlsform_path) submission_path = os.path.join(osm_fixtures_dir, "instance_a.xml") files = [open(path, "rb") for path in paths] - self._make_submission(submission_path, media_file=files) + + with self.captureOnCommitCallbacks(execute=True): + # Ensure on commit callbacks are executed + self._make_submission(submission_path, media_file=files) self.assertTrue(hasattr(self, "instance")) self.assertEqual(self.instance.attachments.all().count(), len(files)) diff --git a/onadata/libs/tests/utils/test_export_tools.py b/onadata/libs/tests/utils/test_export_tools.py index 33106bd034..f621a5b557 100644 --- a/onadata/libs/tests/utils/test_export_tools.py +++ b/onadata/libs/tests/utils/test_export_tools.py @@ -102,7 +102,10 @@ def test_generate_osm_export(self): self._publish_xls_file_and_set_xform(xlsform_path) submission_path = os.path.join(osm_fixtures_dir, "instance_a.xml") count = Attachment.objects.filter(extension="osm").count() - self._make_submission_w_attachment(submission_path, paths) + + with self.captureOnCommitCallbacks(execute=True): + # Ensure on commit callbacks are executed + self._make_submission_w_attachment(submission_path, paths) self.assertTrue(Attachment.objects.filter(extension="osm").count() > count) options = {"extension": Attachment.OSM}