本文整理汇总了Python中onadata.libs.utils.export_tools.ExportBuilder.split_select_multiples方法的典型用法代码示例。如果您正苦于以下问题:Python ExportBuilder.split_select_multiples方法的具体用法?Python ExportBuilder.split_select_multiples怎么用?Python ExportBuilder.split_select_multiples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类onadata.libs.utils.export_tools.ExportBuilder
的用法示例。
在下文中一共展示了ExportBuilder.split_select_multiples方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_split_select_multiples_works
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import split_select_multiples [as 别名]
def test_split_select_multiples_works(self):
select_multiples = {
"children/fav_colors": ["children/fav_colors/red", "children/fav_colors/blue", "children/fav_colors/pink"]
}
row = {"children/name": "Mike", "children/age": 5, "children/fav_colors": "red blue"}
new_row = ExportBuilder.split_select_multiples(row, select_multiples)
expected_row = {
"children/name": "Mike",
"children/age": 5,
"children/fav_colors": "red blue",
"children/fav_colors/red": True,
"children/fav_colors/blue": True,
"children/fav_colors/pink": False,
}
self.assertEqual(new_row, expected_row)
row = {"children/name": "Mike", "children/age": 5}
new_row = ExportBuilder.split_select_multiples(row, select_multiples)
expected_row = {
"children/name": "Mike",
"children/age": 5,
"children/fav_colors/red": None,
"children/fav_colors/blue": None,
"children/fav_colors/pink": None,
}
self.assertEqual(new_row, expected_row)
示例2: test_split_select_multiples_works_when_data_is_blank
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import split_select_multiples [as 别名]
def test_split_select_multiples_works_when_data_is_blank(self):
select_multiples =\
{
'children/fav_colors': [
'children/fav_colors/red', 'children/fav_colors/blue',
'children/fav_colors/pink']
}
row = \
{
'children/name': 'Mike',
'children/age': 5,
'children/fav_colors': ''
}
new_row = ExportBuilder.split_select_multiples(
row, select_multiples)
expected_row = \
{
'children/name': 'Mike',
'children/age': 5,
'children/fav_colors': '',
'children/fav_colors/red': None,
'children/fav_colors/blue': None,
'children/fav_colors/pink': None
}
self.assertEqual(new_row, expected_row)
示例3: test_split_select_multiples_works
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import split_select_multiples [as 别名]
def test_split_select_multiples_works(self):
select_multiples =\
{
'children/fav_colors': [
'children/fav_colors/red', 'children/fav_colors/blue',
'children/fav_colors/pink']
}
row = \
{
'children/name': 'Mike',
'children/age': 5,
'children/fav_colors': 'red blue'
}
new_row = ExportBuilder.split_select_multiples(
row, select_multiples)
expected_row = \
{
'children/name': 'Mike',
'children/age': 5,
'children/fav_colors': 'red blue',
'children/fav_colors/red': True,
'children/fav_colors/blue': True,
'children/fav_colors/pink': False
}
self.assertEqual(new_row, expected_row)
row = \
{
'children/name': 'Mike',
'children/age': 5,
}
new_row = ExportBuilder.split_select_multiples(
row, select_multiples)
expected_row = \
{
'children/name': 'Mike',
'children/age': 5,
'children/fav_colors/red': None,
'children/fav_colors/blue': None,
'children/fav_colors/pink': None
}
self.assertEqual(new_row, expected_row)
示例4: test_split_select_multiples_works_when_data_is_blank
# 需要导入模块: from onadata.libs.utils.export_tools import ExportBuilder [as 别名]
# 或者: from onadata.libs.utils.export_tools.ExportBuilder import split_select_multiples [as 别名]
def test_split_select_multiples_works_when_data_is_blank(self):
select_multiples = {
"children/fav_colors": ["children/fav_colors/red", "children/fav_colors/blue", "children/fav_colors/pink"]
}
row = {"children/name": "Mike", "children/age": 5, "children/fav_colors": ""}
new_row = ExportBuilder.split_select_multiples(row, select_multiples)
expected_row = {
"children/name": "Mike",
"children/age": 5,
"children/fav_colors": "",
"children/fav_colors/red": None,
"children/fav_colors/blue": None,
"children/fav_colors/pink": None,
}
self.assertEqual(new_row, expected_row)