Skip to content

Commit

Permalink
Change root node for created submissions to data
Browse files Browse the repository at this point in the history
By default XLSForms set the default node to 'data'
  • Loading branch information
DavisRayM committed Aug 4, 2020
1 parent 05d29f5 commit 19323ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions onadata/apps/api/tests/viewsets/test_xform_submission_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,16 @@ def test_rapidpro_post_submission(self):
self.assertContains(response, 'Successful submission', status_code=201)
self.assertTrue(response.has_header('Date'))
self.assertEqual(response['Location'], 'http://testserver/submission')
# InstanceID is returned as uuid:<uuid>
# Retrieving the uuid without the prefix in order to retrieve
# the actual instance
uuid = response.data.get('instanceID').split(':')[1]
instance = Instance.objects.get(uuid=uuid)
expected_xml = (
"<?xml version='1.0' ?><data id="
"'transportation_2011_07_25'><fruit_name>orange"
"</fruit_name></data>")
self.assertEqual(instance.xml, expected_xml)

def test_legacy_rapidpro_post_submission(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion onadata/libs/serializers/data_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def create_submission(request, username, data_dict, xform_id):
"""
Returns validated data object instances
"""
xml_string = dict2xform(data_dict, xform_id)
xml_string = dict2xform(data_dict, xform_id, root='data')
xml_file = BytesIO(xml_string.encode('utf-8'))

error, instance = safe_create_instance(username, xml_file, [], None,
Expand Down

0 comments on commit 19323ec

Please sign in to comment.