mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +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:
		| @@ -1,13 +1,16 @@ | |||||||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||||
| import types | import types | ||||||
| from unittest import TestCase | from unittest import TestCase | ||||||
|  | from datetime import datetime, timedelta | ||||||
|  |  | ||||||
| from django.core.exceptions import ValidationError | from django.core.exceptions import ValidationError | ||||||
| from django.core.validators import ( | from django.core.validators import ( | ||||||
|         validate_integer, validate_email, RequiredIfOtherFieldBlank, |         validate_integer, validate_email, RequiredIfOtherFieldBlank, | ||||||
|         validate_slug, validate_ipv4_address |         validate_slug, validate_ipv4_address, MaxValueValidator, | ||||||
|  |         MinValueValidator | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|  | now = datetime.now() | ||||||
| class TestSimpleValidators(TestCase): | class TestSimpleValidators(TestCase): | ||||||
|     pass |     pass | ||||||
|  |  | ||||||
| @@ -53,6 +56,15 @@ SIMPLE_VALIDATORS_VALUES = ( | |||||||
|     (validate_ipv4_address, '25.1.1.', ValidationError), |     (validate_ipv4_address, '25.1.1.', ValidationError), | ||||||
|     (validate_ipv4_address, '25,1,1,1', ValidationError), |     (validate_ipv4_address, '25,1,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): | def get_simple_test_func(validator, expected, value, num): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user