|
1 # -*- coding: utf-8 -*- |
|
2 # Tests for the contrib/localflavor/ CZ Form Fields |
|
3 |
|
4 tests = r""" |
|
5 # CZPostalCodeField ######################################################### |
|
6 |
|
7 >>> from django.contrib.localflavor.cz.forms import CZPostalCodeField |
|
8 >>> f = CZPostalCodeField() |
|
9 >>> f.clean('84545x') |
|
10 Traceback (most recent call last): |
|
11 ... |
|
12 ValidationError: [u'Enter a postal code in the format XXXXX or XXX XX.'] |
|
13 >>> f.clean('91909') |
|
14 u'91909' |
|
15 >>> f.clean('917 01') |
|
16 u'91701' |
|
17 >>> f.clean('12345') |
|
18 u'12345' |
|
19 >>> f.clean('123456') |
|
20 Traceback (most recent call last): |
|
21 ... |
|
22 ValidationError: [u'Enter a postal code in the format XXXXX or XXX XX.'] |
|
23 >>> f.clean('1234') |
|
24 Traceback (most recent call last): |
|
25 ... |
|
26 ValidationError: [u'Enter a postal code in the format XXXXX or XXX XX.'] |
|
27 >>> f.clean('123 4') |
|
28 Traceback (most recent call last): |
|
29 ... |
|
30 ValidationError: [u'Enter a postal code in the format XXXXX or XXX XX.'] |
|
31 |
|
32 # CZRegionSelect ############################################################ |
|
33 |
|
34 >>> from django.contrib.localflavor.cz.forms import CZRegionSelect |
|
35 >>> w = CZRegionSelect() |
|
36 >>> w.render('regions', 'TT') |
|
37 u'<select name="regions">\n<option value="PR">Prague</option>\n<option value="CE">Central Bohemian Region</option>\n<option value="SO">South Bohemian Region</option>\n<option value="PI">Pilsen Region</option>\n<option value="CA">Carlsbad Region</option>\n<option value="US">Usti Region</option>\n<option value="LB">Liberec Region</option>\n<option value="HK">Hradec Region</option>\n<option value="PA">Pardubice Region</option>\n<option value="VY">Vysocina Region</option>\n<option value="SM">South Moravian Region</option>\n<option value="OL">Olomouc Region</option>\n<option value="ZL">Zlin Region</option>\n<option value="MS">Moravian-Silesian Region</option>\n</select>' |
|
38 |
|
39 # CZBirthNumberField ######################################################## |
|
40 |
|
41 >>> from django.contrib.localflavor.cz.forms import CZBirthNumberField |
|
42 >>> f = CZBirthNumberField() |
|
43 >>> f.clean('880523/1237') |
|
44 u'880523/1237' |
|
45 >>> f.clean('8805231237') |
|
46 u'8805231237' |
|
47 >>> f.clean('880523/000') |
|
48 u'880523/000' |
|
49 >>> f.clean('880523000') |
|
50 u'880523000' |
|
51 >>> f.clean('882101/0011') |
|
52 u'882101/0011' |
|
53 >>> f.clean('880523/1237', 'm') |
|
54 u'880523/1237' |
|
55 >>> f.clean('885523/1231', 'f') |
|
56 u'885523/1231' |
|
57 >>> f.clean('123456/12') |
|
58 Traceback (most recent call last): |
|
59 ... |
|
60 ValidationError: [u'Enter a birth number in the format XXXXXX/XXXX or XXXXXXXXXX.'] |
|
61 >>> f.clean('123456/12345') |
|
62 Traceback (most recent call last): |
|
63 ... |
|
64 ValidationError: [u'Enter a birth number in the format XXXXXX/XXXX or XXXXXXXXXX.'] |
|
65 >>> f.clean('12345612') |
|
66 Traceback (most recent call last): |
|
67 ... |
|
68 ValidationError: [u'Enter a birth number in the format XXXXXX/XXXX or XXXXXXXXXX.'] |
|
69 >>> f.clean('12345612345') |
|
70 Traceback (most recent call last): |
|
71 ... |
|
72 ValidationError: [u'Enter a birth number in the format XXXXXX/XXXX or XXXXXXXXXX.'] |
|
73 >>> f.clean('881523/0000', 'm') |
|
74 Traceback (most recent call last): |
|
75 ... |
|
76 ValidationError: [u'Enter a valid birth number.'] |
|
77 >>> f.clean('885223/0000', 'm') |
|
78 Traceback (most recent call last): |
|
79 ... |
|
80 ValidationError: [u'Enter a valid birth number.'] |
|
81 >>> f.clean('881223/0000', 'f') |
|
82 Traceback (most recent call last): |
|
83 ... |
|
84 ValidationError: [u'Enter a valid birth number.'] |
|
85 >>> f.clean('886523/0000', 'f') |
|
86 Traceback (most recent call last): |
|
87 ... |
|
88 ValidationError: [u'Enter a valid birth number.'] |
|
89 >>> f.clean('880523/1239') |
|
90 Traceback (most recent call last): |
|
91 ... |
|
92 ValidationError: [u'Enter a valid birth number.'] |
|
93 >>> f.clean('8805231239') |
|
94 Traceback (most recent call last): |
|
95 ... |
|
96 ValidationError: [u'Enter a valid birth number.'] |
|
97 >>> f.clean('990101/0011') |
|
98 Traceback (most recent call last): |
|
99 ... |
|
100 ValidationError: [u'Enter a valid birth number.'] |
|
101 |
|
102 # CZICNumberField ######################################################## |
|
103 |
|
104 >>> from django.contrib.localflavor.cz.forms import CZICNumberField |
|
105 >>> f = CZICNumberField() |
|
106 >>> f.clean('12345679') |
|
107 u'12345679' |
|
108 >>> f.clean('12345601') |
|
109 u'12345601' |
|
110 >>> f.clean('12345661') |
|
111 u'12345661' |
|
112 >>> f.clean('12345610') |
|
113 u'12345610' |
|
114 >>> f.clean('1234567') |
|
115 Traceback (most recent call last): |
|
116 ... |
|
117 ValidationError: [u'Enter a valid IC number.'] |
|
118 >>> f.clean('12345660') |
|
119 Traceback (most recent call last): |
|
120 ... |
|
121 ValidationError: [u'Enter a valid IC number.'] |
|
122 >>> f.clean('12345600') |
|
123 Traceback (most recent call last): |
|
124 ... |
|
125 ValidationError: [u'Enter a valid IC number.'] |
|
126 """ |