| 1 | # -*- coding: utf-8 -*- |
| 2 | # Tests for the contrib/localflavor/ RO form fields. |
| 3 | |
| 4 | tests = r""" |
| 5 | >>> from django.contrib.localflavor.ro.forms import * |
| 6 | |
| 7 | ##ROCIFField ################################################################ |
| 8 | |
| 9 | f = ROCIFField() |
| 10 | f.clean('21694681') |
| 11 | u'21694681' |
| 12 | f.clean('RO21694681') |
| 13 | u'21694681' |
| 14 | f.clean('21694680') |
| 15 | Traceback (most recent call last): |
| 16 | ... |
| 17 | ValidationError: [u'Enter a valid CIF'] |
| 18 | f.clean('21694680000') |
| 19 | Traceback (most recent call last): |
| 20 | ... |
| 21 | ValidationError: [u'Ensure this value has at most 10 characters (it has 11).'] |
| 22 | f.clean('0') |
| 23 | Traceback (most recent call last): |
| 24 | ... |
| 25 | ValidationError: [u'Ensure this value has at least 2 characters (it has 1).'] |
| 26 | f.clean(None) |
| 27 | Traceback (most recent call last): |
| 28 | ... |
| 29 | ValidationError: [u'This field is required.'] |
| 30 | f.clean('') |
| 31 | Traceback (most recent call last): |
| 32 | ... |
| 33 | ValidationError: [u'This field is required.'] |
| 34 | |
| 35 | ##ROCNPField ################################################################# |
| 36 | |
| 37 | f = ROCNPField() |
| 38 | f.clean('1981211204489') |
| 39 | u'1981211204489' |
| 40 | f.clean('1981211204487') |
| 41 | Traceback (most recent call last): |
| 42 | ... |
| 43 | ValidationError: [u'Enter a valid CNP'] |
| 44 | f.clean('1981232204489') |
| 45 | Traceback (most recent call last): |
| 46 | ... |
| 47 | ValidationError: [u'Enter a valid CNP'] |
| 48 | f.clean('9981211204489') |
| 49 | Traceback (most recent call last): |
| 50 | ... |
| 51 | ValidationError: [u'Enter a valid CNP'] |
| 52 | f.clean('9981211209') |
| 53 | Traceback (most recent call last): |
| 54 | ... |
| 55 | ValidationError: [u'Ensure this value has at least 13 characters (it has 10).'] |
| 56 | f.clean('19812112044891') |
| 57 | Traceback (most recent call last): |
| 58 | ... |
| 59 | ValidationError: [u'Ensure this value has at most 13 characters (it has 14).'] |
| 60 | f.clean('') |
| 61 | Traceback (most recent call last): |
| 62 | ... |
| 63 | ValidationError: [u'This field is required.'] |
| 64 | |
| 65 | ##ROCountyField ############################################################## |
| 66 | |
| 67 | f = ROCountyField() |
| 68 | f.clean('CJ') |
| 69 | 'CJ' |
| 70 | f.clean('cj') |
| 71 | 'CJ' |
| 72 | f.clean('Argeş') |
| 73 | 'AG' |
| 74 | f.clean('argeş') |
| 75 | 'AG' |
| 76 | f.clean('Arges') |
| 77 | Traceback (most recent call last): |
| 78 | ... |
| 79 | ValidationError: [u'Enter a Romanian county code or name.'] |
| 80 | f.clean('') |
| 81 | Traceback (most recent call last): |
| 82 | ... |
| 83 | ValidationError: [u'This field is required.'] |
| 84 | |
| 85 | ##ROCountySelect ############################################################# |
| 86 | |
| 87 | f = ROCountySelect() |
| 88 | f.render('county','CJ') |
| 89 | u'<select name="county">\n<option value="AB">Alba</option>\n<option value="AR">A |
| 90 | rad</option>\n<option value="AG">Arge\u015f</option>\n<option value="BC">Bac\u01 |
| 91 | 03u</option>\n<option value="BH">Bihor</option>\n<option value="BN">Bistri\u0163 |
| 92 | a-N\u0103s\u0103ud</option>\n<option value="BT">Boto\u015fani</option>\n<option |
| 93 | value="BV">Bra\u015fov</option>\n<option value="BR">Br\u0103ila</option>\n<optio |
| 94 | n value="B">Bucure\u015fti</option>\n<option value="BZ">Buz\u0103u</option>\n<op |
| 95 | tion value="CS">Cara\u015f-Severin</option>\n<option value="CL">C\u0103l\u0103ra |
| 96 | \u015fi</option>\n<option value="CJ" selected="selected">Cluj</option>\n<option |
| 97 | value="CT">Constan\u0163a</option>\n<option value="CV">Covasna</option>\n<option |
| 98 | value="DB">D\xe2mbovi\u0163a</option>\n<option value="DJ">Dolj</option>\n<optio |
| 99 | n value="GL">Gala\u0163i</option>\n<option value="GR">Giurgiu</option>\n<option |
| 100 | value="GJ">Gorj</option>\n<option value="HR">Harghita</option>\n<option value="H |
| 101 | D">Hunedoara</option>\n<option value="IL">Ialomi\u0163a</option>\n<option value= |
| 102 | "IS">Ia\u015fi</option>\n<option value="IF">Ilfov</option>\n<option value="MM">M |
| 103 | aramure\u015f</option>\n<option value="MH">Mehedin\u0163i</option>\n<option valu |
| 104 | e="MS">Mure\u015f</option>\n<option value="NT">Neam\u0163</option>\n<option valu |
| 105 | e="OT">Olt</option>\n<option value="PH">Prahova</option>\n<option value="SM">Sat |
| 106 | u Mare</option>\n<option value="SJ">S\u0103laj</option>\n<option value="SB">Sibi |
| 107 | u</option>\n<option value="SV">Suceava</option>\n<option value="TR">Teleorman</o |
| 108 | ption>\n<option value="TM">Timi\u015f</option>\n<option value="TL">Tulcea</optio |
| 109 | n>\n<option value="VS">Vaslui</option>\n<option value="VL">V\xe2lcea</option>\n< |
| 110 | option value="VN">Vrancea</option>\n</select>' |
| 111 | |
| 112 | ##ROIBANField ################################################################# |
| 113 | |
| 114 | f = ROIBANField() |
| 115 | f.clean('RO56RZBR0000060003291177') |
| 116 | u'RO56RZBR0000060003291177' |
| 117 | f.clean('RO56RZBR0000060003291176') |
| 118 | Traceback (most recent call last): |
| 119 | ... |
| 120 | ValidationError: [u'Enter a valid IBAN in ROXX-XXXX-XXXX-XXXX-XXXX-XXXX format'] |
| 121 | |
| 122 | f.clean('RO56-RZBR-0000-0600-0329-1177') |
| 123 | u'RO56RZBR0000060003291177' |
| 124 | f.clean('AT61 1904 3002 3457 3201') |
| 125 | Traceback (most recent call last): |
| 126 | ... |
| 127 | ValidationError: [u'Enter a valid IBAN in ROXX-XXXX-XXXX-XXXX-XXXX-XXXX format'] |
| 128 | |
| 129 | f.clean('RO56RZBR000006000329117') |
| 130 | Traceback (most recent call last): |
| 131 | ... |
| 132 | ValidationError: [u'Ensure this value has at least 24 characters (it has 23).'] |
| 133 | f.clean('') |
| 134 | Traceback (most recent call last): |
| 135 | ... |
| 136 | ValidationError: [u'This field is required.'] |
| 137 | |
| 138 | ##ROPhoneNumberField ########################################################## |
| 139 | |
| 140 | f = ROPhoneNumberField() |
| 141 | f.clean('0264485936') |
| 142 | u'0264485936' |
| 143 | f.clean('(0264)-485936') |
| 144 | u'0264485936' |
| 145 | f.clean('02644859368') |
| 146 | Traceback (most recent call last): |
| 147 | ... |
| 148 | ValidationError: [u'Phone numbers must be in XXXX-XXXXXX format.'] |
| 149 | f.clean('026448593') |
| 150 | Traceback (most recent call last): |
| 151 | ... |
| 152 | ValidationError: [u'Ensure this value has at least 10 characters (it has 9).'] |
| 153 | f.clean(None) |
| 154 | Traceback (most recent call last): |
| 155 | ... |
| 156 | ValidationError: [u'This field is required.'] |
| 157 | |
| 158 | ##ROPostalCodeField ########################################################### |
| 159 | |
| 160 | f = ROPostalCodeField() |
| 161 | f.clean('400473') |
| 162 | u'400473' |
| 163 | f.clean('40047') |
| 164 | Traceback (most recent call last): |
| 165 | ... |
| 166 | ValidationError: [u'Ensure this value has at least 6 characters (it has 5).'] |
| 167 | f.clean('4004731') |
| 168 | Traceback (most recent call last): |
| 169 | ... |
| 170 | ValidationError: [u'Ensure this value has at most 6 characters (it has 7).'] |
| 171 | f.clean('') |
| 172 | Traceback (most recent call last): |
| 173 | ... |
| 174 | ValidationError: [u'This field is required.'] |
| 175 | """ |