Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[soc2009/model-validation] test MinValueValidator, [Max|Min]LengthVal…

…idator

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11458 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 15fb81c3444f7965cb3717a524d9d101b923ea4f 1 parent 9578491
@HonzaKral HonzaKral authored
Showing with 25 additions and 3 deletions.
  1. +25 −3 tests/modeltests/validators/tests.py
View
28 tests/modeltests/validators/tests.py
@@ -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()
@@ -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):
Please sign in to comment.
Something went wrong with that request. Please try again.