Skip to content

Commit

Permalink
move "missing headers" test into new format
Browse files Browse the repository at this point in the history
  • Loading branch information
dorey committed Dec 16, 2015
1 parent 3dcf1f4 commit 896956b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
Binary file not shown.
Binary file not shown.
18 changes: 0 additions & 18 deletions pyxform/tests/bug_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,24 +229,6 @@ def runTest(self):
"Found " + str(len(warnings)) + " warnings")


class MissingHeaderColumnsTest(unittest.TestCase):
def test_choices_headers_missing(self):
filename = "no_header_on_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)

def test_survey_headers_missing(self):
filename = "no_header_on_survey_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 TestChoiceNameAsType(unittest.TestCase):
def test_choice_name_as_type(self):
filename = "choice_name_as_type.xls"
Expand Down
33 changes: 33 additions & 0 deletions pyxform/tests_v1/test_bug_missing_headers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from pyxform_test_case import PyxformTestCase


class MissingHeaders(PyxformTestCase):
'''
when survey and choices columns are missing headers, it is helpful to see
an error message that prompts the user to include necessary headers.
'''
def test_missing_survey_headers(self):
self.assertPyxformXform(
md="""
| survey | | |
| | select_one list | S1 |
""",
errored=True,
error__contains=[
'missing important column headers',
])

def test_missing_choice_headers(self):
self.assertPyxformXform(
md="""
| survey | | | |
| | type | label | name |
| | select_one list | S1 | s1 |
| choices | | | |
| | list | option a | a |
| | list | option b | b |
""",
errored=True,
error__contains=[
"has columns 'list name', 'name', and 'label'",
])

0 comments on commit 896956b

Please sign in to comment.