| 1 | # -*- coding: utf-8 -*- |
| 2 | # Tests for the contrib/localflavor/ AT form fields. |
| 3 | |
| 4 | tests = r""" |
| 5 | # ATZipCodeField ########################################################### |
| 6 | |
| 7 | >>> from django.contrib.localflavor.at.forms import ATZipCodeField |
| 8 | >>> f = ATZipCodeField() |
| 9 | >>> f.clean('1150') |
| 10 | u'1150' |
| 11 | >>> f.clean('4020') |
| 12 | u'4020' |
| 13 | >>> f.clean('8020') |
| 14 | u'8020' |
| 15 | >>> f.clean('111222') |
| 16 | Traceback (most recent call last): |
| 17 | ... |
| 18 | ValidationError: [u'Enter a zip code in the format XXXX.'] |
| 19 | >>> f.clean('eeffee') |
| 20 | Traceback (most recent call last): |
| 21 | ... |
| 22 | ValidationError: [u'Enter a zip code in the format XXXX.'] |
| 23 | >>> f.clean(u'') |
| 24 | Traceback (most recent call last): |
| 25 | ... |
| 26 | ValidationError: [u'This field is required.'] |
| 27 | >>> f.clean(None) |
| 28 | Traceback (most recent call last): |
| 29 | ... |
| 30 | ValidationError: [u'This field is required.'] |
| 31 | >>> f.clean('') |
| 32 | Traceback (most recent call last): |
| 33 | ... |
| 34 | ValidationError: [u'This field is required.'] |
| 35 | |
| 36 | |
| 37 | >>> f = ATZipCodeField(required=False) |
| 38 | >>> f.clean('1150') |
| 39 | u'1150' |
| 40 | >>> f.clean('4020') |
| 41 | u'4020' |
| 42 | >>> f.clean('8020') |
| 43 | u'8020' |
| 44 | >>> f.clean('111222') |
| 45 | Traceback (most recent call last): |
| 46 | ... |
| 47 | ValidationError: [u'Enter a zip code in the format XXXX.'] |
| 48 | >>> f.clean('eeffee') |
| 49 | Traceback (most recent call last): |
| 50 | ... |
| 51 | ValidationError: [u'Enter a zip code in the format XXXX.'] |
| 52 | >>> f.clean(None) |
| 53 | u'' |
| 54 | >>> f.clean('') |
| 55 | u'' |
| 56 | >>> f.clean(u'') |
| 57 | u'' |
| 58 | |
| 59 | # ATStateSelect ################################################################## |
| 60 | |
| 61 | >>> from django.contrib.localflavor.at.forms import ATStateSelect |
| 62 | >>> f = ATStateSelect() |
| 63 | >>> f.render('bundesland', 'WI') |
| 64 | u'<select name="bundesland">\n<option value="BL">Burgenland</option>\n<option value="KA">Carinthia</option>\n<option value="NO">Lower Austria</option>\n<option value="OO">Upper Austria</option>\n<option value="SA">Salzburg</option>\n<option value="ST">Styria</option>\n<option value="TI">Tyrol</option>\n<option value="VO">Vorarlberg</option>\n<option value="WI" selected="selected">Vienna</option>\n</select>' |
| 65 | |
| 66 | """ |