def test_different_doc_types_ordering(self): schema = self._create_schema([ GeopointItem(path=[PathNode(name='one')]), ScalarItem(path=[PathNode(name='two')]), ScalarItem(path=[PathNode(name='three')]), ScalarItem(path=[PathNode(name='one')]), ]) ordered_schema = self._create_schema([ ScalarItem(path=[PathNode(name='two')]), ScalarItem(path=[PathNode(name='one')]), ScalarItem(path=[PathNode(name='three')]), GeopointItem(path=[PathNode(name='one')]), ]) schema = CaseExportDataSchema._reorder_schema_from_schema( schema, ordered_schema, ) self._assert_item_order( schema, [], [ ScalarItem(path=[PathNode(name='two')]), ScalarItem(path=[PathNode(name='one')]), ScalarItem(path=[PathNode(name='three')]), GeopointItem(path=[PathNode(name='one')]), ], )
def test_get_headers(self): column = SplitGPSExportColumn( item=GeopointItem(path=[PathNode(name='form'), PathNode(name='geo')]), label='geo-label', ) result = column.get_headers(split_column=True) self.assertEqual(len(result), 4) result = column.get_headers(split_column=False) self.assertEqual(result, ['geo-label'])
def test_get_value(self): column = SplitGPSExportColumn( item=GeopointItem(path=[PathNode(name='form'), PathNode(name='geo')]) ) result = column.get_value('domain', 'docid', {'form': {'geo': '10 20'}}, [], split_column=True) self.assertEqual(result, ['10', '20', EMPTY_VALUE, EMPTY_VALUE]) result = column.get_value('domain', 'docid', {'form': {'geo': '10 20'}}, [], split_column=False) self.assertEqual(result, '10 20') result = column.get_value('domain', 'docid', {'form': {'geo': None}}, [], split_column=True) self.assertEqual(result, [MISSING_VALUE] * 4)
'The version of CommCare that was used to submit this form')), ExportColumn(tags=[PROPERTY_TAG_INFO], label='deviceID', item=ExportItem(path=[ PathNode(name='form'), PathNode(name='meta'), PathNode(name='deviceID') ]), is_advanced=True, help_text=_("The id of the device that submitted this form")), SplitGPSExportColumn( tags=[PROPERTY_TAG_INFO], label='location', item=GeopointItem(path=[ PathNode(name='form'), PathNode(name='meta'), PathNode(name='location') ]), is_advanced=True, help_text=_("GPS capture when opening the form"), ), ExportColumn(tags=[PROPERTY_TAG_APP], label='app_id', item=ExportItem(path=[PathNode(name='app_id')]), is_advanced=True, help_text=_("The id of the app that this form is part of")), ExportColumn( tags=[PROPERTY_TAG_APP], label='build_id', item=ExportItem(path=[PathNode(name='build_id')]), is_advanced=True,
help_text=_('The version of CommCare and the app that was used to submit this form')), ExportColumn( tags=[PROPERTY_TAG_INFO], label='deviceID', item=ExportItem( path=[PathNode(name='form'), PathNode(name='meta'), PathNode(name='deviceID')], datatype=DATA_TYPE_STRING, ), is_advanced=True, help_text=_("The ID of the device that submitted this form") ), SplitGPSExportColumn( tags=[PROPERTY_TAG_INFO], label='location', item=GeopointItem( path=[PathNode(name='form'), PathNode(name='meta'), PathNode(name='location')], datatype=DATA_TYPE_STRING, ), is_advanced=True, help_text=_("GPS capture when opening the form"), ), ExportColumn( tags=[PROPERTY_TAG_APP], label='app_id', item=ExportItem(path=[PathNode(name='app_id')], datatype=DATA_TYPE_STRING), is_advanced=True, help_text=_("The ID of the app that this form is part of") ), ExportColumn( tags=[PROPERTY_TAG_APP], label='build_id', item=ExportItem(path=[PathNode(name='build_id')], datatype=DATA_TYPE_STRING),