PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/forms/localflavor/at.py

https://code.google.com/p/mango-py/
Python | 45 lines | 42 code | 3 blank | 0 comment | 2 complexity | e8977e102ab8f70a0865009aa68ca2bd MD5 | raw file
 1from django.contrib.localflavor.at.forms import (ATZipCodeField, ATStateSelect,
 2    ATSocialSecurityNumberField)
 3
 4from utils import LocalFlavorTestCase
 5
 6
 7class ATLocalFlavorTests(LocalFlavorTestCase):
 8    def test_ATStateSelect(self):
 9        f = ATStateSelect()
10        out = u'''<select name="bundesland">
11<option value="BL">Burgenland</option>
12<option value="KA">Carinthia</option>
13<option value="NO">Lower Austria</option>
14<option value="OO">Upper Austria</option>
15<option value="SA">Salzburg</option>
16<option value="ST">Styria</option>
17<option value="TI">Tyrol</option>
18<option value="VO">Vorarlberg</option>
19<option value="WI" selected="selected">Vienna</option>
20</select>'''
21        self.assertEqual(f.render('bundesland', 'WI'), out)
22
23    def test_ATZipCodeField(self):
24        error_format = [u'Enter a zip code in the format XXXX.']
25        valid = {
26            '1150': '1150',
27            '4020': '4020',
28            '8020': '8020',
29        }
30        invalid = {
31            '111222': error_format,
32            'eeffee': error_format,
33        }
34        self.assertFieldOutput(ATZipCodeField, valid, invalid)
35
36    def test_ATSocialSecurityNumberField(self):
37        error_format = [u'Enter a valid Austrian Social Security Number in XXXX XXXXXX format.']
38        valid = {
39            '1237 010180': '1237 010180',
40        }
41        invalid = {
42            '1237 010181': error_format,
43            '12370 010180': error_format,
44        }
45        self.assertFieldOutput(ATSocialSecurityNumberField, valid, invalid)