2010-11-19 19:33:07 +00:00
|
|
|
from django.contrib.localflavor.de.forms import (DEZipCodeField, DEStateSelect,
|
|
|
|
DEIdentityCardNumberField)
|
2007-09-19 23:40:47 +00:00
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
from django.test import SimpleTestCase
|
2007-09-19 23:40:47 +00:00
|
|
|
|
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
class DELocalFlavorTests(SimpleTestCase):
|
2010-11-19 19:33:07 +00:00
|
|
|
def test_DEStateSelect(self):
|
|
|
|
f = DEStateSelect()
|
|
|
|
out = u'''<select name="states">
|
|
|
|
<option value="BW">Baden-Wuerttemberg</option>
|
|
|
|
<option value="BY">Bavaria</option>
|
|
|
|
<option value="BE">Berlin</option>
|
|
|
|
<option value="BB">Brandenburg</option>
|
|
|
|
<option value="HB">Bremen</option>
|
|
|
|
<option value="HH">Hamburg</option>
|
|
|
|
<option value="HE">Hessen</option>
|
|
|
|
<option value="MV">Mecklenburg-Western Pomerania</option>
|
|
|
|
<option value="NI">Lower Saxony</option>
|
|
|
|
<option value="NW">North Rhine-Westphalia</option>
|
|
|
|
<option value="RP">Rhineland-Palatinate</option>
|
|
|
|
<option value="SL">Saarland</option>
|
|
|
|
<option value="SN">Saxony</option>
|
|
|
|
<option value="ST">Saxony-Anhalt</option>
|
|
|
|
<option value="SH">Schleswig-Holstein</option>
|
|
|
|
<option value="TH" selected="selected">Thuringia</option>
|
|
|
|
</select>'''
|
2012-01-31 20:36:11 +00:00
|
|
|
self.assertHTMLEqual(f.render('states', 'TH'), out)
|
2007-09-19 23:40:47 +00:00
|
|
|
|
2010-11-19 19:33:07 +00:00
|
|
|
def test_DEZipCodeField(self):
|
|
|
|
error_format = [u'Enter a zip code in the format XXXXX.']
|
|
|
|
valid = {
|
|
|
|
'99423': '99423',
|
|
|
|
}
|
|
|
|
invalid = {
|
|
|
|
' 99423': error_format,
|
|
|
|
}
|
|
|
|
self.assertFieldOutput(DEZipCodeField, valid, invalid)
|
2007-09-19 23:40:47 +00:00
|
|
|
|
2010-11-19 19:33:07 +00:00
|
|
|
def test_DEIdentityCardNumberField(self):
|
|
|
|
error_format = [u'Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format.']
|
|
|
|
valid = {
|
|
|
|
'7549313035D-6004103-0903042-0': '7549313035D-6004103-0903042-0',
|
|
|
|
'9786324830D 6104243 0910271 2': '9786324830D-6104243-0910271-2',
|
|
|
|
}
|
|
|
|
invalid = {
|
|
|
|
'0434657485D-6407276-0508137-9': error_format,
|
|
|
|
}
|
|
|
|
self.assertFieldOutput(DEIdentityCardNumberField, valid, invalid)
|