App Engine Python SDK version 1.7.4 (2)
[gae.git] / python / lib / django_1_4 / tests / regressiontests / localflavor / be / tests.py
blob6cfdfb3ffabaf8e75fec09ab9cdf72223fe98df7
1 from django.contrib.localflavor.be.forms import (BEPostalCodeField,
2 BEPhoneNumberField, BERegionSelect, BEProvinceSelect)
4 from django.test import SimpleTestCase
7 class BELocalFlavorTests(SimpleTestCase):
8 def test_BEPostalCodeField(self):
9 error_format = [u'Enter a valid postal code in the range and format 1XXX - 9XXX.']
10 valid = {
11 u'1451': '1451',
12 u'2540': '2540',
14 invalid = {
15 '0287': error_format,
16 '14309': error_format,
17 '873': error_format,
18 '35 74': error_format,
19 '859A': error_format,
21 self.assertFieldOutput(BEPostalCodeField, valid, invalid)
23 def test_BEPhoneNumberField(self):
24 error_format = [
25 ('Enter a valid phone number in one of the formats 0x xxx xx xx, '
26 '0xx xx xx xx, 04xx xx xx xx, 0x/xxx.xx.xx, 0xx/xx.xx.xx, '
27 '04xx/xx.xx.xx, 0x.xxx.xx.xx, 0xx.xx.xx.xx, 04xx.xx.xx.xx, '
28 '0xxxxxxxx or 04xxxxxxxx.')
30 valid = {
31 u'01 234 56 78': '01 234 56 78',
32 u'01/234.56.78': '01/234.56.78',
33 u'01.234.56.78': '01.234.56.78',
34 u'012 34 56 78': '012 34 56 78',
35 u'012/34.56.78': '012/34.56.78',
36 u'012.34.56.78': '012.34.56.78',
37 u'0412 34 56 78': '0412 34 56 78',
38 u'0412/34.56.78': '0412/34.56.78',
39 u'0412.34.56.78': '0412.34.56.78',
40 u'012345678': '012345678',
41 u'0412345678': '0412345678',
43 invalid = {
44 '01234567': error_format,
45 '12/345.67.89': error_format,
46 '012/345.678.90': error_format,
47 '012/34.56.789': error_format,
48 '0123/45.67.89': error_format,
49 '012/345 678 90': error_format,
50 '012/34 56 789': error_format,
51 '012.34 56 789': error_format,
53 self.assertFieldOutput(BEPhoneNumberField, valid, invalid)
55 def test_BERegionSelect(self):
56 f = BERegionSelect()
57 out = u'''<select name="regions">
58 <option value="BRU">Brussels Capital Region</option>
59 <option value="VLG" selected="selected">Flemish Region</option>
60 <option value="WAL">Wallonia</option>
61 </select>'''
62 self.assertHTMLEqual(f.render('regions', 'VLG'), out)
64 def test_BEProvinceSelect(self):
65 f = BEProvinceSelect()
66 out = u'''<select name="provinces">
67 <option value="VAN">Antwerp</option>
68 <option value="BRU">Brussels</option>
69 <option value="VOV">East Flanders</option>
70 <option value="VBR">Flemish Brabant</option>
71 <option value="WHT">Hainaut</option>
72 <option value="WLG" selected="selected">Liege</option>
73 <option value="VLI">Limburg</option>
74 <option value="WLX">Luxembourg</option>
75 <option value="WNA">Namur</option>
76 <option value="WBR">Walloon Brabant</option>
77 <option value="VWV">West Flanders</option>
78 </select>'''
79 self.assertHTMLEqual(f.render('provinces', 'WLG'), out)