diff --git a/onadata/apps/api/tests/viewsets/test_xform_viewset.py b/onadata/apps/api/tests/viewsets/test_xform_viewset.py index b8ed6508b0..261f939706 100644 --- a/onadata/apps/api/tests/viewsets/test_xform_viewset.py +++ b/onadata/apps/api/tests/viewsets/test_xform_viewset.py @@ -1381,8 +1381,12 @@ def test_publish_invalid_xls_form(self): response = view(request) self.assertEqual(response.status_code, 400) self.assertEqual(response.get('Cache-Control'), None) - error_msg = 'In strict mode, the XForm ID must be a valid slug'\ - ' and contain no spaces.' + error_msg = ('In strict mode, the XForm ID must be ' + 'a valid slug and contain no spaces.' + ' Please ensure that you have set an' + ' id_string in the settings sheet or ' + 'have modified the filename to not ' + 'contain any spaces.') self.assertEqual(response.data.get('text'), error_msg) path = os.path.join( diff --git a/onadata/apps/logger/models/xform.py b/onadata/apps/logger/models/xform.py index e1797f9433..93e3510a03 100644 --- a/onadata/apps/logger/models/xform.py +++ b/onadata/apps/logger/models/xform.py @@ -164,7 +164,8 @@ def check_version_set(survey): def _expand_select_all_that_apply(d, key, e): - if e and e.bind.get(u"type") == u"select": + if e and e.bind.get(u"type") == u"string"\ + and e.type == MULTIPLE_SELECT_TYPE: options_selected = d[key].split() for child in e.children: new_key = child.get_abbreviated_xpath() @@ -864,7 +865,10 @@ def save(self, *args, **kwargs): not re.search(r"^[\w-]+$", self.id_string): raise XLSFormError( _(u'In strict mode, the XForm ID must be a ' - 'valid slug and contain no spaces.')) + 'valid slug and contain no spaces. Please ensure' + ' that you have set an id_string in the settings sheet ' + 'or have modified the filename to not contain' + ' any spaces.')) if not self.sms_id_string and (update_fields is None or 'id_string' in update_fields): diff --git a/onadata/apps/main/tests/test_form_errors.py b/onadata/apps/main/tests/test_form_errors.py index 346f7117dc..1600e7d70e 100644 --- a/onadata/apps/main/tests/test_form_errors.py +++ b/onadata/apps/main/tests/test_form_errors.py @@ -93,12 +93,12 @@ def test_spaced_xlsform(self): self.xform.save() xls_path = os.path.join(self.this_directory, "fixtures", "transportation", "tutorial .xls") - msg = ("The name 'tutorial ' is an invalid XML tag, it contains an" - " invalid character ' '. Names must begin with a letter, colon," - " or underscore, subsequent characters can include numbers, " - "dashes, and periods") + msg = ("In strict mode, the XForm ID must be a valid slug" + " and contain no spaces. Please ensure that you " + "have set an id_string in the settings sheet or" + " have modified the filename to not contain any spaces.") self.assertRaisesMessage( - PyXFormError, msg, self._publish_xls_file, xls_path) + XLSFormError, msg, self._publish_xls_file, xls_path) self.assertEquals(XForm.objects.count(), count) def test_choice_duplicate_error(self):