Skip to content

Commit

Permalink
[soc2009/model-validation] test MinValueValidator, [Max|Min]LengthVal…
Browse files Browse the repository at this point in the history
…idator

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11458 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
honzakral committed Aug 15, 2009
1 parent 9578491 commit 15fb81c
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions tests/modeltests/validators/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

from django.core.exceptions import ValidationError
from django.core.validators import (
validate_integer, validate_email, RequiredIfOtherFieldBlank,
validate_slug, validate_ipv4_address, MaxValueValidator,
MinValueValidator
validate_integer,
validate_email, validate_slug, validate_ipv4_address,
MaxValueValidator, MinValueValidator,
MaxLengthValidator, MinLengthValidator,
RequiredIfOtherFieldBlank,
)

now = datetime.now()
Expand Down Expand Up @@ -65,6 +67,26 @@ class TestSimpleValidators(TestCase):

(MaxValueValidator(0), 1, ValidationError),
(MaxValueValidator(now), now + timedelta(days=1), ValidationError),

(MinValueValidator(-10), -10, None),
(MinValueValidator(-10), 10, None),
(MinValueValidator(-10), 0, None),
(MinValueValidator(now), now, None),
(MinValueValidator(now), now + timedelta(days=1), None),

(MinValueValidator(0), -1, ValidationError),
(MinValueValidator(now), now - timedelta(days=1), ValidationError),

(MaxLengthValidator(10), '', None),
(MaxLengthValidator(10), 10*'x', None),

(MaxLengthValidator(10), 15*'x', ValidationError),

(MinLengthValidator(10), 15*'x', None),
(MinLengthValidator(10), 10*'x', None),

(MinLengthValidator(10), '', ValidationError),

)

def get_simple_test_func(validator, expected, value, num):
Expand Down

0 comments on commit 15fb81c

Please sign in to comment.