mirror of https://github.com/django/django.git
100 lines
21 KiB
Python
100 lines
21 KiB
Python
|
# -*- coding: utf-8 -*-
|
||
|
# Tests for the contrib/localflavor/ FI form fields.
|
||
|
|
||
|
tests = r"""
|
||
|
# FIZipCodeField #############################################################
|
||
|
|
||
|
FIZipCodeField validates that the data is a valid FI zipcode.
|
||
|
>>> from django.contrib.localflavor.fi.forms import FIZipCodeField
|
||
|
>>> f = FIZipCodeField()
|
||
|
>>> f.clean('20540')
|
||
|
u'20540'
|
||
|
>>> f.clean('20101')
|
||
|
u'20101'
|
||
|
>>> f.clean('20s40')
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'Enter a zip code in the format XXXXX.']
|
||
|
>>> f.clean('205401')
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'Enter a zip code in the format XXXXX.']
|
||
|
>>> f.clean(None)
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'This field is required.']
|
||
|
>>> f.clean('')
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'This field is required.']
|
||
|
|
||
|
>>> f = FIZipCodeField(required=False)
|
||
|
>>> f.clean('20540')
|
||
|
u'20540'
|
||
|
>>> f.clean('20101')
|
||
|
u'20101'
|
||
|
>>> f.clean('20s40')
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'Enter a zip code in the format XXXXX.']
|
||
|
>>> f.clean('205401')
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'Enter a zip code in the format XXXXX.']
|
||
|
>>> f.clean(None)
|
||
|
u''
|
||
|
>>> f.clean('')
|
||
|
u''
|
||
|
|
||
|
# FIMunicipalitySelect ###############################################################
|
||
|
|
||
|
A Select widget that uses a list of Finnish municipalities as its choices.
|
||
|
>>> from django.contrib.localflavor.fi.forms import FIMunicipalitySelect
|
||
|
>>> w = FIMunicipalitySelect()
|
||
|
>>> unicode(w.render('municipalities', 'turku'))
|
||
|
u'<select name="municipalities">\n<option value="akaa">Akaa</option>\n<option value="alaharma">Alah\xe4rm\xe4</option>\n<option value="alajarvi">Alaj\xe4rvi</option>\n<option value="alastaro">Alastaro</option>\n<option value="alavieska">Alavieska</option>\n<option value="alavus">Alavus</option>\n<option value="anjalankoski">Anjalankoski</option>\n<option value="artjarvi">Artj\xe4rvi</option>\n<option value="asikkala">Asikkala</option>\n<option value="askainen">Askainen</option>\n<option value="askola">Askola</option>\n<option value="aura">Aura</option>\n<option value="brando">Br\xe4nd\xf6</option>\n<option value="dragsfjard">Dragsfj\xe4rd</option>\n<option value="eckero">Ecker\xf6</option>\n<option value="elimaki">Elim\xe4ki</option>\n<option value="eno">Eno</option>\n<option value="enonkoski">Enonkoski</option>\n<option value="enontekio">Enonteki\xf6</option>\n<option value="espoo">Espoo</option>\n<option value="eura">Eura</option>\n<option value="eurajoki">Eurajoki</option>\n<option value="evijarvi">Evij\xe4rvi</option>\n<option value="finstrom">Finstr\xf6m</option>\n<option value="forssa">Forssa</option>\n<option value="foglo">F\xf6gl\xf6</option>\n<option value="geta">Geta</option>\n<option value="haapajarvi">Haapaj\xe4rvi</option>\n<option value="haapavesi">Haapavesi</option>\n<option value="hailuoto">Hailuoto</option>\n<option value="halikko">Halikko</option>\n<option value="halsua">Halsua</option>\n<option value="hamina">Hamina</option>\n<option value="hammarland">Hammarland</option>\n<option value="hankasalmi">Hankasalmi</option>\n<option value="hanko">Hanko</option>\n<option value="harjavalta">Harjavalta</option>\n<option value="hartola">Hartola</option>\n<option value="hattula">Hattula</option>\n<option value="hauho">Hauho</option>\n<option value="haukipudas">Haukipudas</option>\n<option value="hausjarvi">Hausj\xe4rvi</option>\n<option value="heinola">Heinola</option>\n<option value="heinavesi">Hein\xe4vesi</option>\n<option value="helsinki">Helsinki</option>\n<option value="himanka">Himanka</option>\n<option value="hirvensalmi">Hirvensalmi</option>\n<option value="hollola">Hollola</option>\n<option value="honkajoki">Honkajoki</option>\n<option value="houtskari">Houtskari</option>\n<option value="huittinen">Huittinen</option>\n<option value="humppila">Humppila</option>\n<option value="hyrynsalmi">Hyrynsalmi</option>\n<option value="hyvinkaa">Hyvink\xe4\xe4</option>\n<option value="hameenkoski">H\xe4meenkoski</option>\n<option value="hameenkyro">H\xe4meenkyr\xf6</option>\n<option value="hameenlinna">H\xe4meenlinna</option>\n<option value="ii">Ii</option>\n<option value="iisalmi">Iisalmi</option>\n<option value="iitti">Iitti</option>\n<option value="ikaalinen">Ikaalinen</option>\n<option value="ilmajoki">Ilmajoki</option>\n<option value="ilomantsi">Ilomantsi</option>\n<option value="imatra">Imatra</option>\n<option value="inari">Inari</option>\n<option value="inio">Ini\xf6</option>\n<option value="inkoo">Inkoo</option>\n<option value="isojoki">Isojoki</option>\n<option value="isokyro">Isokyr\xf6</option>\n<option value="jaala">Jaala</option>\n<option value="jalasjarvi">Jalasj\xe4rvi</option>\n<option value="janakkala">Janakkala</option>\n<option value="joensuu">Joensuu</option>\n<option value="jokioinen">Jokioinen</option>\n<option value="jomala">Jomala</option>\n<option value="joroinen">Joroinen</option>\n<option value="joutsa">Joutsa</option>\n<option value="joutseno">Joutseno</option>\n<option value="juankoski">Juankoski</option>\n<option value="jurva">Jurva</option>\n<option value="juuka">Juuka</option>\n<option value="juupajoki">Juupajoki</option>\n<option value="juva">Juva</option>\n<option value="jyvaskyla">Jyv\xe4skyl\xe4</option>\n<option value="jyvaskylan_mlk">Jyv\xe4skyl\xe4n maalaiskunta</option>\n<option value="jamijarvi">J\xe4mij\xe4rvi</option>\n<option value="jamsa">J\xe4ms\xe4</option>\n<option value="jamsankoski">J\xe4ms\xe4nkoski</option>\n<option value="jarvenpaa">J\xe4rvenp\xe4\xe4</option>\n<option value="kaarina">Kaarina</option>\n<option value="kaavi">Kaavi</option>\n<option value="kajaan
|
||
|
|
||
|
# FISocialSecurityNumber ##############################################################
|
||
|
|
||
|
>>> from django.contrib.localflavor.fi.forms import FISocialSecurityNumber
|
||
|
>>> f = FISocialSecurityNumber()
|
||
|
>>> f.clean('010101-0101')
|
||
|
u'010101-0101'
|
||
|
>>> f.clean('010101+0101')
|
||
|
u'010101+0101'
|
||
|
>>> f.clean('010101A0101')
|
||
|
u'010101A0101'
|
||
|
>>> f.clean('101010-0102')
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'Enter a valid Finnish social security number.']
|
||
|
>>> f.clean('10a010-0101')
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'Enter a valid Finnish social security number.']
|
||
|
>>> f.clean('101010-0\xe401')
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'Enter a valid Finnish social security number.']
|
||
|
>>> f.clean('101010b0101')
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'Enter a valid Finnish social security number.']
|
||
|
>>> f.clean('')
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'This field is required.']
|
||
|
|
||
|
>>> f.clean(None)
|
||
|
Traceback (most recent call last):
|
||
|
...
|
||
|
ValidationError: [u'This field is required.']
|
||
|
>>> f = FISocialSecurityNumber(required=False)
|
||
|
>>> f.clean('010101-0101')
|
||
|
u'010101-0101'
|
||
|
>>> f.clean(None)
|
||
|
u''
|
||
|
>>> f.clean('')
|
||
|
u''
|
||
|
"""
|