示例#1
0
    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__'])
示例#2
0
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))
示例#3
0
 def test_unknown_widget_type(self):
     self.assertEqual(TextAnswerForm.get_text_widget("unkown"),
                      (None, None))
示例#4
0
 def test_unknown_widget_type(self):
     self.assertEqual(TextAnswerForm.get_text_widget("unkown"), (None, None))