2012-06-07 16:08:47 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2010-10-15 02:58:10 +00:00
|
|
|
from django.contrib.localflavor.il.forms import (ILPostalCodeField,
|
|
|
|
ILIDNumberField)
|
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
from django.test import SimpleTestCase
|
2010-10-15 02:58:10 +00:00
|
|
|
|
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
class ILLocalFlavorTests(SimpleTestCase):
|
2010-12-18 20:31:22 +00:00
|
|
|
def test_ILPostalCodeField(self):
|
2012-06-07 16:08:47 +00:00
|
|
|
error_format = ['Enter a postal code in the format XXXXX']
|
2010-12-18 20:31:22 +00:00
|
|
|
valid = {
|
|
|
|
'69973': '69973',
|
|
|
|
'699 73': '69973',
|
|
|
|
'12345': '12345',
|
|
|
|
}
|
|
|
|
invalid = {
|
|
|
|
'84545x': error_format,
|
|
|
|
'123456': error_format,
|
|
|
|
'1234': error_format,
|
|
|
|
'123 4': error_format,
|
|
|
|
}
|
|
|
|
self.assertFieldOutput(ILPostalCodeField, valid, invalid)
|
|
|
|
|
|
|
|
def test_ILIDNumberField(self):
|
2012-06-07 16:08:47 +00:00
|
|
|
error_invalid = ['Enter a valid ID number.']
|
2010-12-18 20:31:22 +00:00
|
|
|
valid = {
|
|
|
|
'3933742-3': '39337423',
|
|
|
|
'39337423': '39337423',
|
|
|
|
'039337423': '039337423',
|
|
|
|
'03933742-3': '039337423',
|
|
|
|
'0091': '0091',
|
|
|
|
}
|
|
|
|
invalid = {
|
|
|
|
'123456789': error_invalid,
|
|
|
|
'12345678-9': error_invalid,
|
|
|
|
'012346578': error_invalid,
|
|
|
|
'012346578-': error_invalid,
|
|
|
|
'0001': error_invalid,
|
|
|
|
}
|
|
|
|
self.assertFieldOutput(ILIDNumberField, valid, invalid)
|