def test_validation_error(self): class SomeValidator1(object): def validate(self, s): raise forms.ValidationError("foo") class SomeValidator2(object): def validate(self, s): raise forms.ValidationError("bar") form = TextAnswerForm( read_only=False, interaction_mode="default", validators=[SomeValidator1(), SomeValidator2()], data={"answer": "some answer"}) self.assertFalse(form.is_valid()) self.assertIn("bar", form.errors['__all__'])
def post_form_side_effect(self, page_context, page_data, post_data, files_data): from course.page.text import TextAnswerForm read_only = False return TextAnswerForm( read_only, "default", self.get_validators(), post_data, files_data, widget_type=getattr(self.page_desc, "widget", None))
def test_unknown_widget_type(self): self.assertEqual(TextAnswerForm.get_text_widget("unkown"), (None, None))