Skip to content

Commit

Permalink
Merge pull request #356 from yanokwa/google-submission
Browse files Browse the repository at this point in the history
Google submissions do allow underscores
  • Loading branch information
yanokwa authored Sep 6, 2019
2 parents b756b6d + 972bee5 commit a9fd520
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 25 deletions.
13 changes: 0 additions & 13 deletions pyxform/tests/xls2json_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,6 @@ def test_choice_filter_choice_fields(self):
]
self.assertEqual(choice_filter_survey.to_json_dict()["children"], expected_dict)

def test_underscore_warnings(self):
"""Raise warnings incase there are underscores in column names"""
warnings = []
parse_file_to_json(utils.path_to_text_fixture("hidden.xls"), warnings=warnings)
self.assertGreater(len(warnings), 0)
warning = (
"Google Sheets submissions don't allow underscores in the "
"column name. If you intend to use Google Sheets "
"submissions, replace underscores with hyphens in the "
"following names: hidden_test"
)
self.assertIn(warning, warnings)


class CsvReaderEquivalencyTest(TestCase):
def test_equivalency(self):
Expand Down
2 changes: 1 addition & 1 deletion pyxform/tests/xlsform_spec_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def runTest(self):
warnings = []
pyxform.xls2json.parse_file_to_json(path_to_excel_file, warnings=warnings)
self.assertEquals(
len(warnings), 22, "Found " + str(len(warnings)) + " warnings"
len(warnings), 21, "Found " + str(len(warnings)) + " warnings"
)


Expand Down
11 changes: 0 additions & 11 deletions pyxform/xls2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,6 @@ def workbook_to_json(

# Rows from the survey sheet that should be nested in meta
survey_meta = []
# Google Sheets submissions don't allow underscores in the column name
names_with_underscores = []

for row in survey_sheet:
row_number += 1
Expand Down Expand Up @@ -621,8 +619,6 @@ def workbook_to_json(
question_type = row.get(constants.TYPE)
question_name = row.get(constants.NAME)

if question_name and "_" in question_name:
names_with_underscores.append(question_name)
if not question_type:
# if name and label are also missing,
# then its a comment row, and we skip it with warning
Expand Down Expand Up @@ -1223,13 +1219,6 @@ def replace_prefix(d, prefix):
# Put the row in the json dict as is:
parent_children_array.append(row)

if names_with_underscores:
warnings.append(
"Google Sheets submissions don't allow underscores in the "
"column name. If you intend to use Google Sheets submissions, "
"replace underscores with hyphens in the following names: "
"{}".format(", ".join(names_with_underscores))
)
if len(stack) != 1:
raise PyXFormError(
"Unmatched begin statement: "
Expand Down

0 comments on commit a9fd520

Please sign in to comment.