From 3127298a604dffcab90924554f4b64ce771dc539 Mon Sep 17 00:00:00 2001 From: Davis Raymond Muro Date: Tue, 28 Jan 2020 10:02:03 +0300 Subject: [PATCH] Add test to ensure an error is raised due to choice duplicates - Duplicate choice values are no longer allowed in PyXForm. More info: https://github.com/XLSForm/pyxform/issues/23 - Rename new_cascading_select.xls to duplicate_choice_form.xls --- ...g_select.xls => duplicate_choice_form.xls} | Bin onadata/apps/main/tests/test_form_errors.py | 21 ++++++++++++++++++ 2 files changed, 21 insertions(+) rename onadata/apps/main/tests/fixtures/cascading_selects/{new_cascading_select.xls => duplicate_choice_form.xls} (100%) diff --git a/onadata/apps/main/tests/fixtures/cascading_selects/new_cascading_select.xls b/onadata/apps/main/tests/fixtures/cascading_selects/duplicate_choice_form.xls similarity index 100% rename from onadata/apps/main/tests/fixtures/cascading_selects/new_cascading_select.xls rename to onadata/apps/main/tests/fixtures/cascading_selects/duplicate_choice_form.xls diff --git a/onadata/apps/main/tests/test_form_errors.py b/onadata/apps/main/tests/test_form_errors.py index 750c4567d4..346f7117dc 100644 --- a/onadata/apps/main/tests/test_form_errors.py +++ b/onadata/apps/main/tests/test_form_errors.py @@ -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)