Skip to content

Commit

Permalink
test: Remove medata.delete, reuse & create metadata with different name
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankApiyo committed Jan 9, 2025
1 parent cba0f97 commit d3842c4
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions onadata/libs/tests/utils/test_export_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,11 @@ def test_get_query_params_from_metadata_fn(self):
metadata = MetaData.objects.create(
content_type=ContentType.objects.get_for_model(XForm),
data_type="media",
data_value=f"xform_geojson {self.xform.id} testgeojson",
data_value=f"xform_geojson {self.xform.id} testgeojson2",
extra_data={
"data_title": "start",
"data_fields": "",
"data_geo_field": "qn09",
"data_simple_style": True,
},
object_id=self.xform.id,
)
Expand All @@ -297,32 +296,35 @@ def test_get_query_params_from_metadata_fn(self):
"title": "start",
"fields": "",
"geo_field": "qn09",
"simple_style": True,
},
get_query_params_from_metadata(metadata),
)

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": "start",
"data_fields": "",
"data_geo_field": "qn09",
},
object_id=self.xform.id,
)
metadata.extra_data = {
"data_title": "start",
"data_fields": "one,two",
"data_geo_field": "qn09",
}
self.assertEqual(
{
"title": "start",
"fields": "",
"fields": "one,two",
"geo_field": "qn09",
},
get_query_params_from_metadata(metadata),
)

metadata.extra_data = {
"data_title": "start",
"data_fields": "",
"data_geo_field": "qn09",
"data_simple_style": True,
}
self.assertEqual(
{"title": "start", "fields": "", "geo_field": "qn09", "simple_style": True},
get_query_params_from_metadata(metadata),
)

def test_should_not_create_new_export_when_old_exists(self):
export_type = "geojson"
self._publish_transportation_form_and_submit_instance()
Expand Down Expand Up @@ -402,11 +404,10 @@ def test_should_not_create_new_export_when_old_exists(self):
)

# 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",
data_value=f"xform_geojson {self.xform.id} testgeojson2",
extra_data={
"data_title": "end",
"data_fields": "",
Expand Down

0 comments on commit d3842c4

Please sign in to comment.