Skip to content

Commit

Permalink
Merge pull request #318 from kobotoolbox/properly-flatten-select_one_…
Browse files Browse the repository at this point in the history
…from_file

Properly flatten select_one_from_file
  • Loading branch information
duvld authored Jan 31, 2024
2 parents 3e81c62 + 0831cf7 commit 569d8bf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ skip-string-normalization = true

[tool.pytest.ini_options]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"slow: marks tests as slow (not executed by default - select with '-m \"slow\"')",
]
addopts = [
'-m not slow',
]
3 changes: 3 additions & 0 deletions src/formpack/utils/flatten_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,6 @@ def _flatten_survey_row(row):
row['type'] = '{} {} or_other'.format(_type, _list_name)
else:
row['type'] = '{} {}'.format(_type, _list_name)
elif row['type'] == 'select_one_from_file' and 'file' in row:
_file = row.pop('file')
row['type'] = '{} {}'.format(_type, _file)
12 changes: 12 additions & 0 deletions tests/test_utils_flatten_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ def test_flatten_select_or_other():
assert 'select_from_list_name' not in row0


def test_flatten_select_one_from_file():
s1 = {
'survey': [
{'type': 'select_one_from_file', 'file': 'fruits.csv'}
]
}
flatten_content(s1, in_place=True)
row0 = s1['survey'][0]
assert row0['type'] == 'select_one_from_file fruits.csv'
assert 'file' not in row0


def test_flatten_select():
s1 = {'survey': [{'type': 'select_one', 'select_from_list_name': 'aaa'}]}
flatten_content(s1, in_place=True)
Expand Down

0 comments on commit 569d8bf

Please sign in to comment.