mirror of
https://github.com/django/django.git
synced 2025-07-06 18:59:13 +00:00
[soc2009/model-validation] Added tests for MaxValueValidator
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11193 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
6610e857e3
commit
0e3b83c315
@ -1,13 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import types
|
||||
from unittest import TestCase
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import (
|
||||
validate_integer, validate_email, RequiredIfOtherFieldBlank,
|
||||
validate_slug, validate_ipv4_address
|
||||
validate_slug, validate_ipv4_address, MaxValueValidator,
|
||||
MinValueValidator
|
||||
)
|
||||
|
||||
now = datetime.now()
|
||||
class TestSimpleValidators(TestCase):
|
||||
pass
|
||||
|
||||
@ -53,6 +56,15 @@ SIMPLE_VALIDATORS_VALUES = (
|
||||
(validate_ipv4_address, '25.1.1.', ValidationError),
|
||||
(validate_ipv4_address, '25,1,1,1', ValidationError),
|
||||
(validate_ipv4_address, '25.1 .1.1', ValidationError),
|
||||
|
||||
(MaxValueValidator(10), 10, None),
|
||||
(MaxValueValidator(10), -10, None),
|
||||
(MaxValueValidator(10), 0, None),
|
||||
(MaxValueValidator(now), now, None),
|
||||
(MaxValueValidator(now), now - timedelta(days=1), None),
|
||||
|
||||
(MaxValueValidator(0), 1, ValidationError),
|
||||
(MaxValueValidator(now), now + timedelta(days=1), ValidationError),
|
||||
)
|
||||
|
||||
def get_simple_test_func(validator, expected, value, num):
|
||||
|
Loading…
x
Reference in New Issue
Block a user