Example #1
0
    def test_invalid_value(self):
        ff = LikertFormField()
        with self.assertRaises(ValidationError) as cm:
            ff.clean("InvalidValue")

        self.assertEqual(cm.exception.messages[0],
                         LikertFormField.default_error_messages['invalid'])
Example #2
0
    def test_invalid_value(self):
        ff = LikertFormField()
        with self.assertRaises(ValidationError) as cm:
            ff.clean("InvalidValue")

        self.assertEqual(
            cm.exception.messages[0],
            LikertFormField.default_error_messages['invalid'])
Example #3
0
    def test_max_value_is_settable(self):
        ff = LikertFormField(max_value=5)
        ff.clean(ff.max_value)
        with self.assertRaises(ValidationError) as cm:
            ff.clean(ff.max_value + 1)

        params = {'limit_value': ff.max_value}
        self.assertEqual(
            cm.exception.messages[0],
            LikertFormField.default_error_messages['max_value'] % params)
Example #4
0
    def test_max_value_is_settable(self):
        ff = LikertFormField(max_value=5)
        ff.clean(ff.max_value)
        with self.assertRaises(ValidationError) as cm:
            ff.clean(ff.max_value+1)

        params = {'limit_value': ff.max_value}
        self.assertEqual(
            cm.exception.messages[0],
            LikertFormField.default_error_messages['max_value'] % params)
Example #5
0
    def test_negative_value_raises_validation_error(self):
        ff = LikertFormField()
        negatives = [-1, '-1']
        for v in negatives:
            with self.assertRaises(ValidationError) as cm:
                ff.clean(v)

            params = {'limit_value': ff.min_value}
            self.assertEqual(
                cm.exception.messages[0],
                LikertFormField.default_error_messages['min_value'] % params)
Example #6
0
    def test_negative_value_raises_validation_error(self):
        ff = LikertFormField()
        negatives = [-1, '-1']
        for v in negatives:
            with self.assertRaises(ValidationError) as cm:
                ff.clean(v)

            params = {'limit_value': ff.min_value}
            self.assertEqual(
                cm.exception.messages[0],
                LikertFormField.default_error_messages['min_value'] % params)
Example #7
0
 def test_valid_integer_string_values(self):
     """These are valid responses and should raise no failures"""
     ff = LikertFormField()
     for v in xrange(50 + 1):
         ff.clean(str(v))
Example #8
0
 def test_valid_integer_string_values(self):
     """These are valid responses and should raise no failures"""
     ff = LikertFormField()
     for v in xrange(50+1):
         ff.clean(str(v))