Skip to content

Commit

Permalink
Add test to ensure an error is raised due to choice duplicates
Browse files Browse the repository at this point in the history
- Duplicate choice values are no longer allowed in PyXForm.
  More info: XLSForm/pyxform#23
- Rename new_cascading_select.xls to duplicate_choice_form.xls
  • Loading branch information
DavisRayM committed Jan 28, 2020
1 parent b3568c7 commit 3127298
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions onadata/apps/main/tests/test_form_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,24 @@ def test_spaced_xlsform(self):
self.assertRaisesMessage(
PyXFormError, msg, self._publish_xls_file, xls_path)
self.assertEquals(XForm.objects.count(), count)

def test_choice_duplicate_error(self):
"""
Test that the choice duplicate error is raised if
the "allow_choice_duplicates" setting is not set in the
forms settings sheet
"""
count = XForm.objects.count()
xls_path = os.path.join(
self.this_directory, 'fixtures', 'cascading_selects',
'duplicate_choice_form.xls')
msg = ("There does not seem to be"
" a `allow_choice_duplicates`"
" column header defined in your settings sheet."
" You must have set `allow_choice_duplicates`"
" setting in your settings sheet"
" to have duplicate choice list names"
" in your choices sheet")
self.assertRaisesMessage(
PyXFormError, msg, self._publish_xls_file, xls_path)
self.assertEquals(XForm.objects.count(), count)

0 comments on commit 3127298

Please sign in to comment.