mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #3961 -- Added South African localflavor. Thanks, Russell Cloran.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6843 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
40
tests/regressiontests/forms/localflavor/za.py
Normal file
40
tests/regressiontests/forms/localflavor/za.py
Normal file
@@ -0,0 +1,40 @@
|
||||
tests = r"""
|
||||
# ZAIDField #################################################################
|
||||
|
||||
ZAIDField validates that the date is a valid birthdate and that the value
|
||||
has a valid checksum. It allows spaces and dashes, and returns a plain
|
||||
string of digits.
|
||||
>>> from django.contrib.localflavor.za.forms import ZAIDField
|
||||
>>> f = ZAIDField()
|
||||
>>> f.clean('0002290001003')
|
||||
'0002290001003'
|
||||
>>> f.clean('000229 0001 003')
|
||||
'0002290001003'
|
||||
>>> f.clean('0102290001001')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a valid South African ID number']
|
||||
>>> f.clean('811208')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a valid South African ID number']
|
||||
>>> f.clean('0002290001004')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a valid South African ID number']
|
||||
|
||||
# ZAPostCodeField ###########################################################
|
||||
>>> from django.contrib.localflavor.za.forms import ZAPostCodeField
|
||||
>>> f = ZAPostCodeField()
|
||||
>>> f.clean('abcd')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a valid South African postal code']
|
||||
>>> f.clean('0000')
|
||||
u'0000'
|
||||
>>> f.clean(' 7530')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter a valid South African postal code']
|
||||
|
||||
"""
|
||||
Reference in New Issue
Block a user