-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GeoJSON attachment params to EXPORT_OPTIONS #2757
base: main
Are you sure you want to change the base?
Changes from 3 commits
bf7a780
b31c692
28d28e6
cba0f97
d3842c4
38c8912
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
generate_geojson_export, | ||
generate_kml_export, | ||
generate_osm_export, | ||
get_query_params_from_metadata, | ||
get_repeat_index_tags, | ||
kml_export_data, | ||
parse_request_export_options, | ||
|
@@ -261,7 +262,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 = { | ||
|
@@ -277,6 +278,51 @@ def test_should_not_create_new_export_when_old_exists(self): | |
|
||
self.assertFalse(will_create_new_export) | ||
|
||
def test_get_query_params_from_metadata_fn(self): | ||
self._publish_transportation_form_and_submit_instance() | ||
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", | ||
"data_simple_style": True, | ||
}, | ||
object_id=self.xform.id, | ||
) | ||
self.assertEqual( | ||
{ | ||
"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, | ||
) | ||
self.assertEqual( | ||
{ | ||
"title": "start", | ||
"fields": "", | ||
"geo_field": "qn09", | ||
}, | ||
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() | ||
|
@@ -310,6 +356,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, | ||
|
@@ -336,6 +385,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, | ||
|
@@ -349,6 +401,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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @FrankApiyo Will updating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whenever you create a new linked dataset, a new metadata object is created; So creating a new metadata object more closely simulates what happens in production. (as compared to editing an existing metadata object) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @FrankApiyo Noted. Though l believe since this is a unit test and not an integration test, we should only be interested in the |
||
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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
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 = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FrankApiyo Instead of deleting and creating a new MetaData object, we can update
metadata.extra_data
then dometadata.refresh_from_db()