PageRenderTime 18ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/tests/regressiontests/forms/localflavor/de.py

https://code.google.com/p/mango-py/
Python | 49 lines | 46 code | 3 blank | 0 comment | 2 complexity | 321adbdef6a6b0d3c62b6ff3b4b22734 MD5 | raw file
 1from django.contrib.localflavor.de.forms import (DEZipCodeField, DEStateSelect,
 2    DEIdentityCardNumberField)
 3
 4from utils import LocalFlavorTestCase
 5
 6
 7class DELocalFlavorTests(LocalFlavorTestCase):
 8    def test_DEStateSelect(self):
 9        f = DEStateSelect()
10        out = u'''<select name="states">
11<option value="BW">Baden-Wuerttemberg</option>
12<option value="BY">Bavaria</option>
13<option value="BE">Berlin</option>
14<option value="BB">Brandenburg</option>
15<option value="HB">Bremen</option>
16<option value="HH">Hamburg</option>
17<option value="HE">Hessen</option>
18<option value="MV">Mecklenburg-Western Pomerania</option>
19<option value="NI">Lower Saxony</option>
20<option value="NW">North Rhine-Westphalia</option>
21<option value="RP">Rhineland-Palatinate</option>
22<option value="SL">Saarland</option>
23<option value="SN">Saxony</option>
24<option value="ST">Saxony-Anhalt</option>
25<option value="SH">Schleswig-Holstein</option>
26<option value="TH" selected="selected">Thuringia</option>
27</select>'''
28        self.assertEqual(f.render('states', 'TH'), out)
29
30    def test_DEZipCodeField(self):
31        error_format = [u'Enter a zip code in the format XXXXX.']
32        valid = {
33            '99423': '99423',
34        }
35        invalid = {
36            ' 99423': error_format,
37        }
38        self.assertFieldOutput(DEZipCodeField, valid, invalid)
39
40    def test_DEIdentityCardNumberField(self):
41        error_format = [u'Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format.']
42        valid = {
43            '7549313035D-6004103-0903042-0': '7549313035D-6004103-0903042-0',
44            '9786324830D 6104243 0910271 2': '9786324830D-6104243-0910271-2',
45        }
46        invalid = {
47            '0434657485D-6407276-0508137-9': error_format,
48        }
49        self.assertFieldOutput(DEIdentityCardNumberField, valid, invalid)