Exemplo n.º 1
0
    def test_multiple_form_choice_form_adds_data_instruction_attributes_for_question_options(self):
        question_option_two = QuestionOption.objects.create(text='Option 2', question=self.question, instructions="Some stuff")
        question_option_3 = QuestionOption.objects.create(text='Option 3', question=self.question, instructions="Some stuff")
        question_option_4 = QuestionOption.objects.create(text='Option 4', question=self.question, instructions="Some stuff")

        answer_form = MultiChoiceAnswerForm(initial=self.initial)
        query_set = answer_form._get_response_choices(self.initial)
        widget = answer_form._get_response_widget(query_set)
        self.assertIsInstance(widget, MultiChoiceAnswerSelectWidget)
        self.assertEqual(4, widget.question_options.count())
        self.assertIn(self.question_option_one, widget.question_options)
        self.assertIn(question_option_two, widget.question_options)
        self.assertIn(question_option_3, widget.question_options)
        self.assertIn(question_option_4, widget.question_options)

        self.assertEqual("Choose One", answer_form.fields['response'].empty_label)
Exemplo n.º 2
0
    def test_multiple_form_choice_form_adds_data_instruction_attributes_for_question_options(
            self):
        question_option_two = QuestionOption.objects.create(
            text='Option 2', question=self.question, instructions="Some stuff")
        question_option_3 = QuestionOption.objects.create(
            text='Option 3', question=self.question, instructions="Some stuff")
        question_option_4 = QuestionOption.objects.create(
            text='Option 4', question=self.question, instructions="Some stuff")

        answer_form = MultiChoiceAnswerForm(initial=self.initial)
        query_set = answer_form._get_response_choices(self.initial)
        widget = answer_form._get_response_widget(query_set)
        self.assertIsInstance(widget, MultiChoiceAnswerSelectWidget)
        self.assertEqual(4, widget.question_options.count())
        self.assertIn(self.question_option_one, widget.question_options)
        self.assertIn(question_option_two, widget.question_options)
        self.assertIn(question_option_3, widget.question_options)
        self.assertIn(question_option_4, widget.question_options)

        self.assertEqual("Choose One",
                         answer_form.fields['response'].empty_label)