Skip to content

Commit

Permalink
Merge pull request #141 from moshthepitt/issue-138
Browse files Browse the repository at this point in the history
Issue 138
  • Loading branch information
ukanga authored Aug 2, 2017
2 parents badeb46 + eb41405 commit e747c3e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
10 changes: 0 additions & 10 deletions pyxform/tests/bug_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 17 additions & 0 deletions pyxform/tests_v1/test_sheet_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions pyxform/xls2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit e747c3e

Please sign in to comment.