diff --git a/onadata/apps/api/tests/viewsets/test_data_viewset.py b/onadata/apps/api/tests/viewsets/test_data_viewset.py index af01906a24..a29220e59c 100644 --- a/onadata/apps/api/tests/viewsets/test_data_viewset.py +++ b/onadata/apps/api/tests/viewsets/test_data_viewset.py @@ -3811,6 +3811,7 @@ def test_submissions_deletion_in_progress(self): self.assertEqual(response.status_code, 200) self.assertEqual(len(response.data), 2) + @override_settings(ENABLE_SUBMISSION_PERMANENT_DELETE=True) @patch( "onadata.apps.api.viewsets.data_viewset.delete_xform_submissions_async.delay" ) @@ -3823,7 +3824,6 @@ def test_deletion_of_bulk_submissions_async(self, mock_del_async): records_to_be_deleted = self.xform.instances.all()[:2] instance_ids = ",".join([str(i.pk) for i in records_to_be_deleted]) data = {"instance_ids": instance_ids} - request = self.factory.delete("/", data=data, **self.extra) response = view(request, pk=self.xform.pk) @@ -3834,6 +3834,19 @@ def test_deletion_of_bulk_submissions_async(self, mock_del_async): True, self.user.id, ) + # Permanent deletion + mock_del_async.reset_mock() # Reset mock + data = {"permanent_delete": True, "instance_ids": instance_ids} + request = self.factory.delete("/", data=data, **self.extra) + response = view(request, pk=self.xform.pk) + + self.assertEqual(response.status_code, 200) + mock_del_async.assert_called_once_with( + self.xform.pk, + [str(records_to_be_deleted[0].pk), str(records_to_be_deleted[1].pk)], + False, + self.user.id, + ) class TestOSM(TestAbstractViewSet):