2010-12-12 12:33:50 +08:00
|
|
|
from django.contrib.localflavor.at.forms import (ATZipCodeField, ATStateSelect,
|
|
|
|
ATSocialSecurityNumberField)
|
|
|
|
|
2011-08-23 10:32:37 +08:00
|
|
|
from django.test import SimpleTestCase
|
2010-12-12 12:33:50 +08:00
|
|
|
|
|
|
|
|
2011-08-23 10:32:37 +08:00
|
|
|
class ATLocalFlavorTests(SimpleTestCase):
|
2010-12-12 12:33:50 +08:00
|
|
|
def test_ATStateSelect(self):
|
|
|
|
f = ATStateSelect()
|
|
|
|
out = u'''<select name="bundesland">
|
|
|
|
<option value="BL">Burgenland</option>
|
|
|
|
<option value="KA">Carinthia</option>
|
|
|
|
<option value="NO">Lower Austria</option>
|
|
|
|
<option value="OO">Upper Austria</option>
|
|
|
|
<option value="SA">Salzburg</option>
|
|
|
|
<option value="ST">Styria</option>
|
|
|
|
<option value="TI">Tyrol</option>
|
|
|
|
<option value="VO">Vorarlberg</option>
|
|
|
|
<option value="WI" selected="selected">Vienna</option>
|
|
|
|
</select>'''
|
2012-02-01 04:36:11 +08:00
|
|
|
self.assertHTMLEqual(f.render('bundesland', 'WI'), out)
|
2010-12-12 12:33:50 +08:00
|
|
|
|
|
|
|
def test_ATZipCodeField(self):
|
|
|
|
error_format = [u'Enter a zip code in the format XXXX.']
|
|
|
|
valid = {
|
|
|
|
'1150': '1150',
|
|
|
|
'4020': '4020',
|
|
|
|
'8020': '8020',
|
|
|
|
}
|
|
|
|
invalid = {
|
2011-06-25 20:39:29 +08:00
|
|
|
'0000' : error_format,
|
|
|
|
'0123' : error_format,
|
2010-12-12 12:33:50 +08:00
|
|
|
'111222': error_format,
|
|
|
|
'eeffee': error_format,
|
|
|
|
}
|
|
|
|
self.assertFieldOutput(ATZipCodeField, valid, invalid)
|
|
|
|
|
|
|
|
def test_ATSocialSecurityNumberField(self):
|
|
|
|
error_format = [u'Enter a valid Austrian Social Security Number in XXXX XXXXXX format.']
|
|
|
|
valid = {
|
|
|
|
'1237 010180': '1237 010180',
|
|
|
|
}
|
|
|
|
invalid = {
|
|
|
|
'1237 010181': error_format,
|
|
|
|
'12370 010180': error_format,
|
|
|
|
}
|
|
|
|
self.assertFieldOutput(ATSocialSecurityNumberField, valid, invalid)
|