diff options
author | Justin Bronn <jbronn@gmail.com> | 2008-08-05 17:15:33 +0000 |
---|---|---|
committer | Justin Bronn <jbronn@gmail.com> | 2008-08-05 17:15:33 +0000 |
commit | aa239e3e5405933af6a29dac3cf587b59a099927 (patch) | |
tree | ea2cbd139c9a8cf84c09e0b2008bff70e05927ef /tests/modeltests/validation/models.py | |
parent | 45b73c9a4685809236f84046cc7ffd32a50db958 (diff) | |
download | django-attic/gis.tar.gz |
gis: Merged revisions 7981-8001,8003-8011,8013-8033,8035-8036,8038-8039,8041-8063,8065-8076,8078-8139,8141-8154,8156-8214 via svnmerge from trunk.archive/attic/gisattic/gis
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@8215 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/validation/models.py')
-rw-r--r-- | tests/modeltests/validation/models.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py index 63f9f7a361..7ed9d66674 100644 --- a/tests/modeltests/validation/models.py +++ b/tests/modeltests/validation/models.py @@ -16,6 +16,7 @@ class Person(models.Model): birthdate = models.DateField() favorite_moment = models.DateTimeField() email = models.EmailField() + best_time = models.TimeField() def __unicode__(self): return self.name @@ -28,7 +29,8 @@ __test__ = {'API_TESTS':""" ... 'name': 'John', ... 'birthdate': datetime.date(2000, 5, 3), ... 'favorite_moment': datetime.datetime(2002, 4, 3, 13, 23), -... 'email': 'john@example.com' +... 'email': 'john@example.com', +... 'best_time': datetime.time(16, 20), ... } >>> p = Person(**valid_params) >>> p.validate() @@ -130,6 +132,22 @@ datetime.datetime(2002, 4, 3, 13, 23) >>> 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() {} @@ -153,5 +171,7 @@ u'john@example.com' [u'This field is required.'] >>> errors['birthdate'] [u'This field is required.'] +>>> errors['best_time'] +[u'This field is required.'] """} |