Skip to content

Commit

Permalink
enhance test case
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri committed Nov 29, 2023
1 parent 0a30600 commit 211f412
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions onadata/apps/api/tests/viewsets/test_xform_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,28 +712,31 @@ def test_registration_form(self):
"entities",
"trees_registration.xlsx",
)

with open(path, "rb") as xls_file:
post_data = {"xls_file": xls_file}
request = self.factory.post("/", data=post_data, **self.extra)
response = self.view(request)
self.assertEqual(xforms + 1, XForm.objects.count())
self.assertEqual(response.status_code, 201)
self.assertEqual(EntityList.objects.count(), 1)
self.assertEqual(RegistrationForm.objects.count(), 1)
entity_list = EntityList.objects.first()
reg_form = RegistrationForm.objects.first()
latest_form = XForm.objects.all().order_by("-pk").first()
self.assertEqual(entity_list.name, "trees")
self.assertEqual(reg_form.xform, latest_form)
self.assertEqual(
reg_form.get_save_to(),
{
"geometry": "location",
"species": "species",
"circumference_cm": "circumference",
},
)
self.assertEqual(reg_form.entity_list, entity_list)

self.assertEqual(xforms + 1, XForm.objects.count())
self.assertEqual(response.status_code, 201)
self.assertEqual(EntityList.objects.count(), 1)
self.assertEqual(RegistrationForm.objects.count(), 1)
entity_list = EntityList.objects.first()
reg_form = RegistrationForm.objects.first()
latest_form = XForm.objects.all().order_by("-pk").first()
self.assertEqual(entity_list.name, "trees")
self.assertEqual(reg_form.xform, latest_form)
self.assertEqual(
reg_form.get_save_to(),
{
"geometry": "location",
"species": "species",
"circumference_cm": "circumference",
},
)
self.assertEqual(reg_form.entity_list, entity_list)
self.assertTrue(reg_form.is_active)

def test_follow_up_form(self):
"""Publishing an XLSForm that consumes entities works"""
Expand Down

0 comments on commit 211f412

Please sign in to comment.