diff --git a/onadata/apps/api/tests/viewsets/test_xform_submission_viewset.py b/onadata/apps/api/tests/viewsets/test_xform_submission_viewset.py index 994456e077..0c561eecde 100644 --- a/onadata/apps/api/tests/viewsets/test_xform_submission_viewset.py +++ b/onadata/apps/api/tests/viewsets/test_xform_submission_viewset.py @@ -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: + # Retrieving the actual uuid without the prefix in order to retrieve + # the actual instance + uuid = response.data.get('instanceID').split(':')[1] + instance = Instance.objects.filter(uuid=uuid) + expected_xml = ( + "orange" + "") + self.assertEqual(instance.xml, expected_xml) def test_legacy_rapidpro_post_submission(self): """ diff --git a/onadata/libs/serializers/data_serializer.py b/onadata/libs/serializers/data_serializer.py index 99c4e69808..59e247639c 100644 --- a/onadata/libs/serializers/data_serializer.py +++ b/onadata/libs/serializers/data_serializer.py @@ -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,