Esempio n. 1
0
    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'])
Esempio n. 2
0
    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'])
Esempio n. 3
0
    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)
Esempio n. 4
0
    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'])
Esempio n. 5
0
    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'])
Esempio n. 6
0
    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'])
Esempio n. 7
0
    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)
Esempio n. 8
0
    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'])