equal
deleted
inserted
replaced
|
1 from django.contrib.localflavor.uk.forms import UKPostcodeField |
|
2 |
|
3 from utils import LocalFlavorTestCase |
|
4 |
|
5 |
|
6 class UKLocalFlavorTests(LocalFlavorTestCase): |
|
7 def test_UKPostcodeField(self): |
|
8 error_invalid = [u'Enter a valid postcode.'] |
|
9 valid = { |
|
10 'BT32 4PX': 'BT32 4PX', |
|
11 'GIR 0AA': 'GIR 0AA', |
|
12 'BT324PX': 'BT32 4PX', |
|
13 ' so11aa ': 'SO1 1AA', |
|
14 ' so1 1aa ': 'SO1 1AA', |
|
15 'G2 3wt': 'G2 3WT', |
|
16 'EC1A 1BB': 'EC1A 1BB', |
|
17 'Ec1a1BB': 'EC1A 1BB', |
|
18 } |
|
19 invalid = { |
|
20 '1NV 4L1D': error_invalid, |
|
21 '1NV4L1D': error_invalid, |
|
22 ' b0gUS': error_invalid, |
|
23 } |
|
24 self.assertFieldOutput(UKPostcodeField, valid, invalid) |
|
25 valid = {} |
|
26 invalid = { |
|
27 '1NV 4L1D': [u'Enter a bloody postcode!'], |
|
28 } |
|
29 kwargs = {'error_messages': {'invalid': 'Enter a bloody postcode!'}} |
|
30 self.assertFieldOutput(UKPostcodeField, valid, invalid, field_kwargs=kwargs) |