Skip to content

Commit

Permalink
Add a test case for making a GET request for a deleted dataview
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankApiyo committed Oct 19, 2024
1 parent 02962ec commit 570e254
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions onadata/apps/api/tests/viewsets/test_dataview_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,36 @@ def test_get_dataview_no_perms(self):

self.assertEqual(response.status_code, 200)

def test_can_not_get_deleted_dataview(self):
data = {
"name": "Agriculture Dataview",
"xform": f"http://testserver/api/v1/forms/{self.xform.pk}",
"project": f"http://testserver/api/v1/projects/{self.project.pk}",
"columns": '["name", "age", "gender"]',
"query": '[{"column":"age","filter":">","value":"20"},'
'{"column":"age","filter":"<","value":"50"}]',
}

self._create_dataview(data=data)

view = DataViewViewSet.as_view(
{
"get": "retrieve",
}
)

request = self.factory.get("/", **self.extra)
response = view(request, pk=self.data_view.pk)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data["dataviewid"], self.data_view.pk)

dataview = DataView.objects.get(id=response.data["dataviewid"])
dataview.soft_delete(user=self.user)

request = self.factory.get("/", **self.extra)
response = view(request, pk=self.data_view.pk)
self.assertEqual(response.status_code, 404)

# pylint: disable=invalid-name
def test_dataview_data_filter_integer(self):
data = {
Expand Down

0 comments on commit 570e254

Please sign in to comment.