|
1 from django.contrib.localflavor.sk.forms import (SKRegionSelect, |
|
2 SKPostalCodeField, SKDistrictSelect) |
|
3 |
|
4 from utils import LocalFlavorTestCase |
|
5 |
|
6 |
|
7 class SKLocalFlavorTests(LocalFlavorTestCase): |
|
8 def test_SKRegionSelect(self): |
|
9 f = SKRegionSelect() |
|
10 out = u'''<select name="regions"> |
|
11 <option value="BB">Banska Bystrica region</option> |
|
12 <option value="BA">Bratislava region</option> |
|
13 <option value="KE">Kosice region</option> |
|
14 <option value="NR">Nitra region</option> |
|
15 <option value="PO">Presov region</option> |
|
16 <option value="TN">Trencin region</option> |
|
17 <option value="TT" selected="selected">Trnava region</option> |
|
18 <option value="ZA">Zilina region</option> |
|
19 </select>''' |
|
20 self.assertEqual(f.render('regions', 'TT'), out) |
|
21 |
|
22 def test_SKDistrictSelect(self): |
|
23 f = SKDistrictSelect() |
|
24 out = u'''<select name="Districts"> |
|
25 <option value="BB">Banska Bystrica</option> |
|
26 <option value="BS">Banska Stiavnica</option> |
|
27 <option value="BJ">Bardejov</option> |
|
28 <option value="BN">Banovce nad Bebravou</option> |
|
29 <option value="BR">Brezno</option> |
|
30 <option value="BA1">Bratislava I</option> |
|
31 <option value="BA2">Bratislava II</option> |
|
32 <option value="BA3">Bratislava III</option> |
|
33 <option value="BA4">Bratislava IV</option> |
|
34 <option value="BA5">Bratislava V</option> |
|
35 <option value="BY">Bytca</option> |
|
36 <option value="CA">Cadca</option> |
|
37 <option value="DT">Detva</option> |
|
38 <option value="DK">Dolny Kubin</option> |
|
39 <option value="DS">Dunajska Streda</option> |
|
40 <option value="GA">Galanta</option> |
|
41 <option value="GL">Gelnica</option> |
|
42 <option value="HC">Hlohovec</option> |
|
43 <option value="HE">Humenne</option> |
|
44 <option value="IL">Ilava</option> |
|
45 <option value="KK">Kezmarok</option> |
|
46 <option value="KN">Komarno</option> |
|
47 <option value="KE1">Kosice I</option> |
|
48 <option value="KE2">Kosice II</option> |
|
49 <option value="KE3">Kosice III</option> |
|
50 <option value="KE4">Kosice IV</option> |
|
51 <option value="KEO">Kosice - okolie</option> |
|
52 <option value="KA">Krupina</option> |
|
53 <option value="KM">Kysucke Nove Mesto</option> |
|
54 <option value="LV">Levice</option> |
|
55 <option value="LE">Levoca</option> |
|
56 <option value="LM">Liptovsky Mikulas</option> |
|
57 <option value="LC">Lucenec</option> |
|
58 <option value="MA">Malacky</option> |
|
59 <option value="MT">Martin</option> |
|
60 <option value="ML">Medzilaborce</option> |
|
61 <option value="MI">Michalovce</option> |
|
62 <option value="MY">Myjava</option> |
|
63 <option value="NO">Namestovo</option> |
|
64 <option value="NR">Nitra</option> |
|
65 <option value="NM">Nove Mesto nad Vahom</option> |
|
66 <option value="NZ">Nove Zamky</option> |
|
67 <option value="PE">Partizanske</option> |
|
68 <option value="PK">Pezinok</option> |
|
69 <option value="PN">Piestany</option> |
|
70 <option value="PT">Poltar</option> |
|
71 <option value="PP">Poprad</option> |
|
72 <option value="PB">Povazska Bystrica</option> |
|
73 <option value="PO">Presov</option> |
|
74 <option value="PD">Prievidza</option> |
|
75 <option value="PU">Puchov</option> |
|
76 <option value="RA">Revuca</option> |
|
77 <option value="RS">Rimavska Sobota</option> |
|
78 <option value="RV">Roznava</option> |
|
79 <option value="RK" selected="selected">Ruzomberok</option> |
|
80 <option value="SB">Sabinov</option> |
|
81 <option value="SC">Senec</option> |
|
82 <option value="SE">Senica</option> |
|
83 <option value="SI">Skalica</option> |
|
84 <option value="SV">Snina</option> |
|
85 <option value="SO">Sobrance</option> |
|
86 <option value="SN">Spisska Nova Ves</option> |
|
87 <option value="SL">Stara Lubovna</option> |
|
88 <option value="SP">Stropkov</option> |
|
89 <option value="SK">Svidnik</option> |
|
90 <option value="SA">Sala</option> |
|
91 <option value="TO">Topolcany</option> |
|
92 <option value="TV">Trebisov</option> |
|
93 <option value="TN">Trencin</option> |
|
94 <option value="TT">Trnava</option> |
|
95 <option value="TR">Turcianske Teplice</option> |
|
96 <option value="TS">Tvrdosin</option> |
|
97 <option value="VK">Velky Krtis</option> |
|
98 <option value="VT">Vranov nad Toplou</option> |
|
99 <option value="ZM">Zlate Moravce</option> |
|
100 <option value="ZV">Zvolen</option> |
|
101 <option value="ZC">Zarnovica</option> |
|
102 <option value="ZH">Ziar nad Hronom</option> |
|
103 <option value="ZA">Zilina</option> |
|
104 </select>''' |
|
105 self.assertEqual(f.render('Districts', 'RK'), out) |
|
106 |
|
107 def test_SKPostalCodeField(self): |
|
108 error_format = [u'Enter a postal code in the format XXXXX or XXX XX.'] |
|
109 valid = { |
|
110 '91909': '91909', |
|
111 '917 01': '91701', |
|
112 } |
|
113 invalid = { |
|
114 '84545x': error_format, |
|
115 } |
|
116 self.assertFieldOutput(SKPostalCodeField, valid, invalid) |