|
1 from django.contrib.localflavor.nl.forms import (NLPhoneNumberField, |
|
2 NLZipCodeField, NLSoFiNumberField, NLProvinceSelect) |
|
3 |
|
4 from utils import LocalFlavorTestCase |
|
5 |
|
6 |
|
7 class NLLocalFlavorTests(LocalFlavorTestCase): |
|
8 def test_NLProvinceSelect(self): |
|
9 f = NLProvinceSelect() |
|
10 out = u'''<select name="provinces"> |
|
11 <option value="DR">Drenthe</option> |
|
12 <option value="FL">Flevoland</option> |
|
13 <option value="FR">Friesland</option> |
|
14 <option value="GL">Gelderland</option> |
|
15 <option value="GR">Groningen</option> |
|
16 <option value="LB">Limburg</option> |
|
17 <option value="NB">Noord-Brabant</option> |
|
18 <option value="NH">Noord-Holland</option> |
|
19 <option value="OV" selected="selected">Overijssel</option> |
|
20 <option value="UT">Utrecht</option> |
|
21 <option value="ZE">Zeeland</option> |
|
22 <option value="ZH">Zuid-Holland</option> |
|
23 </select>''' |
|
24 self.assertEqual(f.render('provinces', 'OV'), out) |
|
25 |
|
26 def test_NLPhoneNumberField(self): |
|
27 error_invalid = [u'Enter a valid phone number'] |
|
28 valid = { |
|
29 '012-3456789': '012-3456789', |
|
30 '0123456789': '0123456789', |
|
31 '+31-12-3456789': '+31-12-3456789', |
|
32 '(0123) 456789': '(0123) 456789', |
|
33 } |
|
34 invalid = { |
|
35 'foo': error_invalid, |
|
36 } |
|
37 self.assertFieldOutput(NLPhoneNumberField, valid, invalid) |
|
38 |
|
39 def test_NLZipCodeField(self): |
|
40 error_invalid = [u'Enter a valid postal code'] |
|
41 valid = { |
|
42 '1234ab': '1234 AB', |
|
43 '1234 ab': '1234 AB', |
|
44 '1234 AB': '1234 AB', |
|
45 } |
|
46 invalid = { |
|
47 '0123AB': error_invalid, |
|
48 'foo': error_invalid, |
|
49 } |
|
50 self.assertFieldOutput(NLZipCodeField, valid, invalid) |
|
51 |
|
52 def test_NLSoFiNumberField(self): |
|
53 error_invalid = [u'Enter a valid SoFi number'] |
|
54 valid = { |
|
55 '123456782': '123456782', |
|
56 } |
|
57 invalid = { |
|
58 '000000000': error_invalid, |
|
59 '123456789': error_invalid, |
|
60 'foo': error_invalid, |
|
61 } |
|
62 self.assertFieldOutput(NLSoFiNumberField, valid, invalid) |