Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri committed Nov 18, 2024
1 parent 6b64ed0 commit 39003cd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion onadata/apps/api/tests/viewsets/test_data_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)

Expand All @@ -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):
Expand Down

0 comments on commit 39003cd

Please sign in to comment.