Beispiel #1
0
 def test_id_of_a_non_option(self):
     form_data = self.form_data.copy()
     form_data['response'] = -1
     answer_form = MultiChoiceAnswerForm(form_data, initial=self.initial)
     self.assertFalse(answer_form.is_valid())
     message = 'Select a valid choice. That choice is not one of the available choices.'
     self.assertEqual([message], answer_form.errors['response'])
Beispiel #2
0
 def test_id_of_a_non_option(self):
     form_data = self.form_data.copy()
     form_data['response'] = -1
     answer_form = MultiChoiceAnswerForm(form_data, initial=self.initial)
     self.assertFalse(answer_form.is_valid())
     message = 'Select a valid choice. That choice is not one of the available choices.'
     self.assertEqual([message], answer_form.errors['response'])
Beispiel #3
0
 def test_new_option_is_created_and_saved_as_response_when_specify_field_is_not_empty(self):
     form_data = self.form_data.copy()
     form_data['specified_option'] = 'specified option'
     answer_form = MultiChoiceAnswerForm(form_data, initial=self.initial)
     self.assertTrue(answer_form.is_valid())
     answer_form.save()
     option = QuestionOption.objects.get(text="specified option", question=self.question)
     self.failUnless(MultiChoiceAnswer.objects.filter(response=option, question=self.question))
     as_text = '<input id="id_response" name="response" type="text" value="%d" />' % option.id
     self.assertEqual(as_text, answer_form.visible_fields()[0].as_text())
Beispiel #4
0
 def test_valid(self):
     answer_form = MultiChoiceAnswerForm(self.form_data, initial=self.initial)
     self.assertTrue(answer_form.is_valid())
     self.assertIsNone(answer_form.fields['response'].empty_label)
Beispiel #5
0
 def test_valid(self):
     answer_form = MultiChoiceAnswerForm(self.form_data,
                                         initial=self.initial)
     self.assertTrue(answer_form.is_valid())
     self.assertIsNone(answer_form.fields['response'].empty_label)