PageRenderTime 222ms CodeModel.GetById 86ms app.highlight 3ms RepoModel.GetById 118ms app.codeStats 0ms

/tests/regressiontests/forms/localflavor/uk.py

https://code.google.com/p/mango-py/
Python | 30 lines | 27 code | 3 blank | 0 comment | 0 complexity | ecd108530c6db6bef467a75986a90e28 MD5 | raw file
 1from django.contrib.localflavor.uk.forms import UKPostcodeField
 2
 3from utils import LocalFlavorTestCase
 4
 5
 6class 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)