diff options
| author | Gary Wilson Jr <gary.wilson@gmail.com> | 2008-08-14 15:37:43 +0000 |
|---|---|---|
| committer | Gary Wilson Jr <gary.wilson@gmail.com> | 2008-08-14 15:37:43 +0000 |
| commit | 788de6b5fdef05c1f321868db964ffe31949fbac (patch) | |
| tree | c713b4a9a08fc0e9a00a3142512b82ef8030f497 /tests | |
| parent | 29a9c34c655de418a945aa02295425081d52a024 (diff) | |
Fixed #8206 -- Removed validate methods of Model and Model fields. They are are unsupported for 1.0 and will be replaced with more complete model validation (refs #6845).
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8348 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/validation/__init__.py | 0 | ||||
| -rw-r--r-- | tests/modeltests/validation/models.py | 177 |
2 files changed, 0 insertions, 177 deletions
diff --git a/tests/modeltests/validation/__init__.py b/tests/modeltests/validation/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/modeltests/validation/__init__.py +++ /dev/null diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py deleted file mode 100644 index 7ed9d66674..0000000000 --- a/tests/modeltests/validation/models.py +++ /dev/null @@ -1,177 +0,0 @@ -""" -31. Validation - -This is an experimental feature! - -Each model instance has a validate() method that returns a dictionary of -validation errors in the instance's fields. This method has a side effect -of converting each field to its appropriate Python data type. -""" - -from django.db import models - -class Person(models.Model): - is_child = models.BooleanField() - name = models.CharField(max_length=20) - birthdate = models.DateField() - favorite_moment = models.DateTimeField() - email = models.EmailField() - best_time = models.TimeField() - - def __unicode__(self): - return self.name - -__test__ = {'API_TESTS':""" - ->>> import datetime ->>> valid_params = { -... 'is_child': True, -... 'name': 'John', -... 'birthdate': datetime.date(2000, 5, 3), -... 'favorite_moment': datetime.datetime(2002, 4, 3, 13, 23), -... 'email': 'john@example.com', -... 'best_time': datetime.time(16, 20), -... } ->>> p = Person(**valid_params) ->>> p.validate() -{} - ->>> p = Person(**dict(valid_params, id='23')) ->>> p.validate() -{} ->>> p.id -23 - ->>> p = Person(**dict(valid_params, id='foo')) ->>> p.validate()['id'] -[u'This value must be an integer.'] - ->>> p = Person(**dict(valid_params, id=None)) ->>> p.validate() -{} ->>> repr(p.id) -'None' - ->>> p = Person(**dict(valid_params, is_child='t')) ->>> p.validate() -{} ->>> p.is_child -True - ->>> p = Person(**dict(valid_params, is_child='f')) ->>> p.validate() -{} ->>> p.is_child -False - ->>> p = Person(**dict(valid_params, is_child=True)) ->>> p.validate() -{} ->>> p.is_child -True - ->>> p = Person(**dict(valid_params, is_child=False)) ->>> p.validate() -{} ->>> p.is_child -False - ->>> p = Person(**dict(valid_params, is_child='foo')) ->>> p.validate()['is_child'] -[u'This value must be either True or False.'] - ->>> p = Person(**dict(valid_params, name=u'Jose')) ->>> p.validate() -{} ->>> p.name -u'Jose' - ->>> p = Person(**dict(valid_params, name=227)) ->>> p.validate() -{} ->>> p.name -u'227' - ->>> p = Person(**dict(valid_params, birthdate=datetime.date(2000, 5, 3))) ->>> p.validate() -{} ->>> p.birthdate -datetime.date(2000, 5, 3) - ->>> p = Person(**dict(valid_params, birthdate=datetime.datetime(2000, 5, 3))) ->>> p.validate() -{} ->>> p.birthdate -datetime.date(2000, 5, 3) - ->>> p = Person(**dict(valid_params, birthdate='2000-05-03')) ->>> p.validate() -{} ->>> p.birthdate -datetime.date(2000, 5, 3) - ->>> p = Person(**dict(valid_params, birthdate='2000-5-3')) ->>> p.validate() -{} ->>> p.birthdate -datetime.date(2000, 5, 3) - ->>> p = Person(**dict(valid_params, birthdate='foo')) ->>> p.validate()['birthdate'] -[u'Enter a valid date in YYYY-MM-DD format.'] - ->>> p = Person(**dict(valid_params, favorite_moment=datetime.datetime(2002, 4, 3, 13, 23))) ->>> p.validate() -{} ->>> p.favorite_moment -datetime.datetime(2002, 4, 3, 13, 23) - ->>> p = Person(**dict(valid_params, favorite_moment=datetime.datetime(2002, 4, 3))) ->>> p.validate() -{} ->>> p.favorite_moment -datetime.datetime(2002, 4, 3, 0, 0) - ->>> p = Person(**dict(valid_params, best_time='16:20:00')) ->>> p.validate() -{} ->>> p.best_time -datetime.time(16, 20) - ->>> p = Person(**dict(valid_params, best_time='16:20')) ->>> p.validate() -{} ->>> p.best_time -datetime.time(16, 20) - ->>> p = Person(**dict(valid_params, best_time='bar')) ->>> p.validate()['best_time'] -[u'Enter a valid time in HH:MM[:ss[.uuuuuu]] format.'] - ->>> p = Person(**dict(valid_params, email='john@example.com')) ->>> p.validate() -{} ->>> p.email -'john@example.com' - ->>> p = Person(**dict(valid_params, email=u'john@example.com')) ->>> p.validate() -{} ->>> p.email -u'john@example.com' - ->>> p = Person(**dict(valid_params, email=22)) ->>> p.validate()['email'] -[u'Enter a valid e-mail address.'] - -# Make sure that Date and DateTime return validation errors and don't raise Python errors. ->>> p = Person(name='John Doe', is_child=True, email='abc@def.com') ->>> errors = p.validate() ->>> errors['favorite_moment'] -[u'This field is required.'] ->>> errors['birthdate'] -[u'This field is required.'] ->>> errors['best_time'] -[u'This field is required.'] - -"""} |
