def _get_forms_error_descs(form: UserASForm) -> str: """ Return all the fields and non fields errors in the `UserASForm`, as well as all the fields, non fields, and non form errors of the `AttachmentConfForm` """ formset = form.attachment_conf_form_set return '\n'.join( map(str, [ form.errors, form.non_field_errors(), formset.errors, formset.non_form_errors() ]))
def test_create_too_many(self): """ Submitting the creation form with quota exceeded leads to a form-error. """ form_data = self._get_initial_dict() form_data.update(**self.valid_form_params[0].kwargs) for i in range(get_testuser().max_num_ases()): form = UserASForm(user=get_testuser(), data=form_data) # Check that form is valid, otherwise this test will not make sense self.assertTrue(form.is_valid(), form.errors) form.save() form = UserASForm(user=get_testuser(), data=form_data) self.assertFalse(form.is_valid()) self.assertTrue(any(e.find("quota exceeded") >= 0 for e in form.non_field_errors()), form.errors)