Skip to content

Commit

Permalink
Update GeoJSON export test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankApiyo committed Jan 8, 2025
1 parent bf7a780 commit b31c692
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion onadata/libs/tests/utils/test_export_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def test_should_create_export_when_submission_deleted(self):

self.assertTrue(will_create_new_export)

def test_should_not_create_new_export_when_old_exists(self):
def test_should_not_create_new_export_fn(self):
export_type = "csv"
self._publish_transportation_form_and_submit_instance()
options = {
Expand Down Expand Up @@ -310,6 +310,9 @@ def test_should_not_create_new_export_when_old_exists(self):
self.assertEqual(
{
"dataview_pk": False,
"title": "start",
"fields": "",
"simple_style": True,
"include_hxl": True,
"include_images": True,
"include_labels": False,
Expand All @@ -336,6 +339,9 @@ def test_should_not_create_new_export_when_old_exists(self):
self.assertEqual(
{
"dataview_pk": False,
"title": "start",
"fields": "",
"simple_style": True,
"include_hxl": True,
"include_images": True,
"include_labels": False,
Expand All @@ -349,6 +355,50 @@ def test_should_not_create_new_export_when_old_exists(self):
Export.objects.get(xform=self.xform).options,
)

# New metadata will yield a new export
metadata.delete()
metadata = MetaData.objects.create(
content_type=ContentType.objects.get_for_model(XForm),
data_type="media",
data_value=f"xform_geojson {self.xform.id} testgeojson",
extra_data={
"data_title": "end",
"data_fields": "",
"data_geo_field": "qn09",
"data_simple_style": True,
},
object_id=self.xform.id,
)
_response = custom_response_handler(
request,
self.xform,
{},
export_type,
filename="testgeojson2",
dataview=False,
metadata=metadata,
)
# we generated a new export since the extra_data has been updated
self.assertEqual(2, Export.objects.filter(xform=self.xform).count())
self.assertEqual(
{
"dataview_pk": False,
"title": "end",
"fields": "",
"simple_style": True,
"include_hxl": True,
"include_images": True,
"include_labels": False,
"win_excel_utf8": False,
"group_delimiter": "/",
"include_reviews": False,
"remove_group_name": False,
"include_labels_only": False,
"split_select_multiples": True,
},
Export.objects.filter(xform=self.xform).last().options,
)

def test_should_create_new_export_when_filter_defined(self):
export_type = "csv"
options = {
Expand Down

0 comments on commit b31c692

Please sign in to comment.