2012-06-07 16:08:47 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2010-12-18 20:32:17 +00:00
|
|
|
from django.contrib.localflavor.nl.forms import (NLPhoneNumberField,
|
|
|
|
NLZipCodeField, NLSoFiNumberField, NLProvinceSelect)
|
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
from django.test import SimpleTestCase
|
2010-12-18 20:32:17 +00:00
|
|
|
|
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
class NLLocalFlavorTests(SimpleTestCase):
|
2010-12-18 20:32:17 +00:00
|
|
|
def test_NLProvinceSelect(self):
|
|
|
|
f = NLProvinceSelect()
|
2012-06-07 16:08:47 +00:00
|
|
|
out = '''<select name="provinces">
|
2010-12-18 20:32:17 +00:00
|
|
|
<option value="DR">Drenthe</option>
|
|
|
|
<option value="FL">Flevoland</option>
|
|
|
|
<option value="FR">Friesland</option>
|
|
|
|
<option value="GL">Gelderland</option>
|
|
|
|
<option value="GR">Groningen</option>
|
|
|
|
<option value="LB">Limburg</option>
|
|
|
|
<option value="NB">Noord-Brabant</option>
|
|
|
|
<option value="NH">Noord-Holland</option>
|
|
|
|
<option value="OV" selected="selected">Overijssel</option>
|
|
|
|
<option value="UT">Utrecht</option>
|
|
|
|
<option value="ZE">Zeeland</option>
|
|
|
|
<option value="ZH">Zuid-Holland</option>
|
|
|
|
</select>'''
|
2012-01-31 20:36:11 +00:00
|
|
|
self.assertHTMLEqual(f.render('provinces', 'OV'), out)
|
2010-12-18 20:32:17 +00:00
|
|
|
|
|
|
|
def test_NLPhoneNumberField(self):
|
2012-06-07 16:08:47 +00:00
|
|
|
error_invalid = ['Enter a valid phone number']
|
2010-12-18 20:32:17 +00:00
|
|
|
valid = {
|
|
|
|
'012-3456789': '012-3456789',
|
|
|
|
'0123456789': '0123456789',
|
|
|
|
'+31-12-3456789': '+31-12-3456789',
|
|
|
|
'(0123) 456789': '(0123) 456789',
|
|
|
|
}
|
|
|
|
invalid = {
|
|
|
|
'foo': error_invalid,
|
|
|
|
}
|
|
|
|
self.assertFieldOutput(NLPhoneNumberField, valid, invalid)
|
|
|
|
|
|
|
|
def test_NLZipCodeField(self):
|
2012-06-07 16:08:47 +00:00
|
|
|
error_invalid = ['Enter a valid postal code']
|
2010-12-18 20:32:17 +00:00
|
|
|
valid = {
|
|
|
|
'1234ab': '1234 AB',
|
|
|
|
'1234 ab': '1234 AB',
|
|
|
|
'1234 AB': '1234 AB',
|
|
|
|
}
|
|
|
|
invalid = {
|
|
|
|
'0123AB': error_invalid,
|
|
|
|
'foo': error_invalid,
|
|
|
|
}
|
|
|
|
self.assertFieldOutput(NLZipCodeField, valid, invalid)
|
|
|
|
|
|
|
|
def test_NLSoFiNumberField(self):
|
2012-06-07 16:08:47 +00:00
|
|
|
error_invalid = ['Enter a valid SoFi number']
|
2010-12-18 20:32:17 +00:00
|
|
|
valid = {
|
|
|
|
'123456782': '123456782',
|
|
|
|
}
|
|
|
|
invalid = {
|
|
|
|
'000000000': error_invalid,
|
|
|
|
'123456789': error_invalid,
|
|
|
|
'foo': error_invalid,
|
|
|
|
}
|
|
|
|
self.assertFieldOutput(NLSoFiNumberField, valid, invalid)
|