Skip to content

Commit

Permalink
Merge branch '277-additional-fields-exports' into 277-additional-fiel…
Browse files Browse the repository at this point in the history
…ds-exports--modified-json
  • Loading branch information
joshuaberetta committed Oct 11, 2022
2 parents b71c7c6 + 9fcec12 commit c87f93d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/formpack/utils/expand_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ def _mark_special(**kwargs: str) -> None:
def _expand_type_to_dict(type_str: str) -> Dict[str, Union[str, bool]]:
SELECT_PATTERN = r'^({select_type})\s+(\S+)$'
out = {}
match = re.search('( or.other)$', type_str)
match = re.search('\s+(or.other)$', type_str)
if match:
type_str = type_str.replace(match.groups()[0], '')
type_str = type_str.replace(match.groups()[0], '').strip()
out[OR_OTHER_COLUMN] = True
match = re.search('select_(one|multiple)(_or_other)', type_str)
if match:
Expand Down
2 changes: 0 additions & 2 deletions src/formpack/utils/replace_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,12 @@ def aliases_to_ordered_dict(_d):
'end',
'deviceid',
'phone_number',
'simserial',
'audit',
# meta values
'username',
# reconsider:
'phonenumber',
'imei',
'subscriberid',
# geo
'start-geopoint',
]
Expand Down
9 changes: 9 additions & 0 deletions tests/test_expand_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

def test_expand_selects_with_or_other():
assert _expand_type_to_dict('select_one xx or other').get(_OR_OTHER) == True
assert _expand_type_to_dict('select_one xx or_other').get(_OR_OTHER) == True
assert _expand_type_to_dict('select_one_or_other xx').get(_OR_OTHER) == True
assert (
_expand_type_to_dict('select_multiple_or_other xx').get(_OR_OTHER)
Expand Down Expand Up @@ -56,6 +57,14 @@ def test_expand_select_one_or_other():
assert s1['survey'][0]['select_from_list_name'] == 'dogs'


def test_expand_select_one_or_other_with_spaces():
s1 = {'survey': [{'type': 'select_one dogs or_other'}]}
expand_content(s1, in_place=True)
assert s1['survey'][0]['type'] == 'select_one'
assert s1['survey'][0]['select_from_list_name'] == 'dogs'
assert s1['survey'][0][_OR_OTHER] == True


def test_expand_select_multiple():
s1 = {'survey': [{'type': 'select_multiple dogs'}]}
expand_content(s1, in_place=True)
Expand Down

0 comments on commit c87f93d

Please sign in to comment.