2011-05-03 11:52:20 +00:00
|
|
|
from django.contrib.localflavor.gb.forms import GBPostcodeField
|
2007-09-19 23:40:47 +00:00
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
from django.test import SimpleTestCase
|
2007-09-19 23:40:47 +00:00
|
|
|
|
2010-12-18 20:33:13 +00:00
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
class GBLocalFlavorTests(SimpleTestCase):
|
2011-05-03 11:52:20 +00:00
|
|
|
def test_GBPostcodeField(self):
|
2010-12-18 20:33:13 +00:00
|
|
|
error_invalid = [u'Enter a valid postcode.']
|
|
|
|
valid = {
|
|
|
|
'BT32 4PX': 'BT32 4PX',
|
|
|
|
'GIR 0AA': 'GIR 0AA',
|
|
|
|
'BT324PX': 'BT32 4PX',
|
|
|
|
' so11aa ': 'SO1 1AA',
|
|
|
|
' so1 1aa ': 'SO1 1AA',
|
|
|
|
'G2 3wt': 'G2 3WT',
|
|
|
|
'EC1A 1BB': 'EC1A 1BB',
|
|
|
|
'Ec1a1BB': 'EC1A 1BB',
|
|
|
|
}
|
|
|
|
invalid = {
|
|
|
|
'1NV 4L1D': error_invalid,
|
|
|
|
'1NV4L1D': error_invalid,
|
|
|
|
' b0gUS': error_invalid,
|
|
|
|
}
|
2011-05-03 11:52:20 +00:00
|
|
|
self.assertFieldOutput(GBPostcodeField, valid, invalid)
|
2010-12-18 20:33:13 +00:00
|
|
|
valid = {}
|
|
|
|
invalid = {
|
|
|
|
'1NV 4L1D': [u'Enter a bloody postcode!'],
|
|
|
|
}
|
|
|
|
kwargs = {'error_messages': {'invalid': 'Enter a bloody postcode!'}}
|
2011-05-03 11:52:20 +00:00
|
|
|
self.assertFieldOutput(GBPostcodeField, valid, invalid, field_kwargs=kwargs)
|