Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[soc2009/model-validation] Added tests for MaxValueValidator

  • Loading branch information...
commit 0e3b83c31515c041e8a43736e7dd49ffd835b052 1 parent 6610e85
@HonzaKral HonzaKral authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 tests/modeltests/validators/tests.py
View
14 tests/modeltests/validators/tests.py
@@ -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 @@ class TestSimpleValidators(TestCase):
(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):
Please sign in to comment.
Something went wrong with that request. Please try again.