def test_validation_fails_when_too_many_choices(self): quiz = Quiz(choices=1) q = Question(quiz=quiz) q.choices = ['one', 'too many'] tools.assert_raises(ValidationError, q.full_clean, exclude=['quiz', 'order', 'text'])
def test_validation_fails_when_too_few_choices(self): quiz = Quiz(choices=3) q = Question(quiz=quiz) q.choices = ['just', 'two'] tools.assert_raises(ValidationError, q.full_clean, exclude=['quiz', 'order', 'text'])
def test_choices_set(self): q = Question() q.choices = self.choices tools.assert_equals( Question.SEPARATOR.join( ['choice 1', 'ch2', 'Uaaaaa, we are all gonna die!!!!']), q.choices_data)
def test_validation_passes_for_correct_no_of_choices(self): quiz = Quiz(choices=2) q = Question(quiz=quiz) q.choices = ['just', 'right'] q.full_clean(exclude=['quiz', 'order', 'text'])
def test_choices_set(self): q = Question() q.choices = self.choices tools.assert_equals(Question.SEPARATOR.join(['choice 1', 'ch2', 'Uaaaaa, we are all gonna die!!!!']), q.choices_data)