diff --git a/pyxform/tests/bug_tests.py b/pyxform/tests/bug_tests.py index e4e433613..e67b7dc71 100644 --- a/pyxform/tests/bug_tests.py +++ b/pyxform/tests/bug_tests.py @@ -190,16 +190,6 @@ def runTest(self): workbook_dict['survey'][0][u'bind: relevant'].strip() -class MissingOrBadlyNamedChoicesTest(unittest.TestCase): - def runTest(self): - filename = "badly_named_choices_sheet.xls" - path_to_excel_file = os.path.join(DIR, "bug_example_xls", filename) - workbook_dict = pyxform.xls2json.parse_file_to_workbook_dict( - path_to_excel_file) - with self.assertRaises(pyxform.errors.PyXFormError): - pyxform.xls2json.workbook_to_json(workbook_dict) - - class BadChoicesSheetHeaders(unittest.TestCase): def runTest(self): filename = "spaces_in_choices_header.xls" diff --git a/pyxform/tests_v1/test_sheet_columns.py b/pyxform/tests_v1/test_sheet_columns.py index 91cd45897..79093e2e6 100644 --- a/pyxform/tests_v1/test_sheet_columns.py +++ b/pyxform/tests_v1/test_sheet_columns.py @@ -32,6 +32,23 @@ def test_missing_label(self): error__contains=['no label or hint'], ) + def test_column_case(self): + """ + Ensure that column name is case insensitive + """ + self.assertPyxformXform( + name="mixedcasecolumns", + md=""" + | Survey | | | | + | | Type | name | Label | + | | text | Name | the name | + | | integer | age | the age | + | | text | gender | the gender | + """, + errored=False, + debug=True + ) + class InvalidChoiceSheetColumnsTests(PyxformTestCase): def _simple_choice_ss(self, choice_sheet=None): diff --git a/pyxform/xls2json.py b/pyxform/xls2json.py index 41102f622..17a600e12 100644 --- a/pyxform/xls2json.py +++ b/pyxform/xls2json.py @@ -338,8 +338,9 @@ def workbook_to_json( if warnings is None: warnings = [] is_valid = False - for row in workbook_dict.get('survey', []): - is_valid = 'type' in row + workbook_dict = {x.lower(): y for x,y in workbook_dict.items()} + for row in workbook_dict.get(constants.SURVEY, []): + is_valid = 'type' in [z.lower() for z in row] if is_valid: break if not is_valid: