App Engine Python SDK version 1.7.4 (2)
[gae.git] / python / lib / django_1_4 / tests / modeltests / validation / validators.py
blobd82b95e3ad46fe4ebf3eb088c6e4ee609d16cba6
1 from __future__ import absolute_import
3 from . import ValidationTestCase
4 from .models import ModelToValidate
7 class TestModelsWithValidators(ValidationTestCase):
8 def test_custom_validator_passes_for_correct_value(self):
9 mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=42)
10 self.assertEqual(None, mtv.full_clean())
12 def test_custom_validator_raises_error_for_incorrect_value(self):
13 mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=12)
14 self.assertFailsValidation(mtv.full_clean, ['f_with_custom_validator'])
15 self.assertFieldFailsValidationWithMessage(
16 mtv.full_clean,
17 'f_with_custom_validator',
18 [u'This is not the answer to life, universe and everything!']