示例#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'])
示例#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'])
示例#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)
示例#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'])
示例#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'])
示例#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'])
示例#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)
示例#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'])
示例#9
0
    def test_choices_get(self):
        q = Question(choices_data=Question.SEPARATOR.join(
            ['choice 1', 'ch2', 'Uaaaaa, we are all gonna die!!!!']))

        tools.assert_equals(self.choices, q.choices)