示例#1
0
    def test_choice_multichoice_question_form(self):
        choice_question = ChoiceQuestion.objects.create(
            text="Multichoice question",
            multichoice=True
        )

        choice_question.choices = [
            Choice.objects.create(label='42 what was the question?'),
            Choice.objects.create(label='43'),
        ]

        form = ChoiceQuestionForm(
            question=choice_question,
            content_object=self.member,
        )

        template = get_template_from_string(u"""
                {% load crispy_forms_tags %}
                {% crispy form %}
        """)
        nt.eq_(form.is_valid(), False)
        c = Context({'form': form})
        html = template.render(c)

        nt.assert_true('42 what was the question' in html)

        # test that inline checkboxes are rendering instead of radio buttons
        nt.assert_true('checkbox inline' in html)
示例#2
0
    def test_choice_question_form(self):
        choice_question = ChoiceQuestion.objects.create(
            text="What is the meaning of life?"
        )

        choice_question.choices = [
            Choice.objects.create(label='42 what was the question?'),
            Choice.objects.create(label='43'),
        ]

        form =  ChoiceQuestionForm(
            question=choice_question,
            content_object=self.member,
        )

        template = get_template_from_string(u"""
                {% load crispy_forms_tags %}
                {% crispy form %}
        """)
        nt.eq_(form.is_valid(), False)
        c = Context({'form': form})
        html = template.render(c)

        nt.assert_true('42 what was the question' in html)
示例#3
0
 def choice_form(self, question, data={}):
     return ChoiceQuestionForm(
         data,
         question=question,
         content_object=self.member,
     )