2007-09-19 23:40:47 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Tests for the contrib/localflavor/ PL form fields.
|
|
|
|
|
|
|
|
tests = r"""
|
2008-08-14 04:29:02 +00:00
|
|
|
# PLProvinceSelect ##########################################################
|
2007-09-19 23:40:47 +00:00
|
|
|
|
2008-08-14 04:29:02 +00:00
|
|
|
>>> from django.contrib.localflavor.pl.forms import PLProvinceSelect
|
|
|
|
>>> f = PLProvinceSelect()
|
2007-09-19 23:40:47 +00:00
|
|
|
>>> f.render('voivodeships','pomerania')
|
|
|
|
u'<select name="voivodeships">\n<option value="lower_silesia">Lower Silesia</option>\n<option value="kuyavia-pomerania">Kuyavia-Pomerania</option>\n<option value="lublin">Lublin</option>\n<option value="lubusz">Lubusz</option>\n<option value="lodz">Lodz</option>\n<option value="lesser_poland">Lesser Poland</option>\n<option value="masovia">Masovia</option>\n<option value="opole">Opole</option>\n<option value="subcarpatia">Subcarpatia</option>\n<option value="podlasie">Podlasie</option>\n<option value="pomerania" selected="selected">Pomerania</option>\n<option value="silesia">Silesia</option>\n<option value="swietokrzyskie">Swietokrzyskie</option>\n<option value="warmia-masuria">Warmia-Masuria</option>\n<option value="greater_poland">Greater Poland</option>\n<option value="west_pomerania">West Pomerania</option>\n</select>'
|
|
|
|
|
2008-08-27 23:05:25 +00:00
|
|
|
# PLCountySelect ##########################################################
|
2007-09-19 23:40:47 +00:00
|
|
|
|
2008-08-27 23:05:25 +00:00
|
|
|
>>> from django.contrib.localflavor.pl.forms import PLCountySelect
|
|
|
|
>>> f = PLCountySelect()
|
2007-09-19 23:40:47 +00:00
|
|
|
>>> f.render('administrativeunit','katowice')
|
|
|
|
u'<select name="administrativeunit">\n<option value="wroclaw">Wroc\u0142aw</option>\n<option value="jeleniagora">Jelenia G\xf3ra</option>\n<option value="legnica">Legnica</option>\n<option value="boleslawiecki">boles\u0142awiecki</option>\n<option value="dzierzoniowski">dzier\u017coniowski</option>\n<option value="glogowski">g\u0142ogowski</option>\n<option value="gorowski">g\xf3rowski</option>\n<option value="jaworski">jaworski</option>\n<option value="jeleniogorski">jeleniog\xf3rski</option>\n<option value="kamiennogorski">kamiennog\xf3rski</option>\n<option value="klodzki">k\u0142odzki</option>\n<option value="legnicki">legnicki</option>\n<option value="lubanski">luba\u0144ski</option>\n<option value="lubinski">lubi\u0144ski</option>\n<option value="lwowecki">lw\xf3wecki</option>\n<option value="milicki">milicki</option>\n<option value="olesnicki">ole\u015bnicki</option>\n<option value="olawski">o\u0142awski</option>\n<option value="polkowicki">polkowicki</option>\n<option value="strzelinski">strzeli\u0144ski</option>\n<option value="sredzki">\u015bredzki</option>\n<option value="swidnicki">\u015bwidnicki</option>\n<option value="trzebnicki">trzebnicki</option>\n<option value="walbrzyski">wa\u0142brzyski</option>\n<option value="wolowski">wo\u0142owski</option>\n<option value="wroclawski">wroc\u0142awski</option>\n<option value="zabkowicki">z\u0105bkowicki</option>\n<option value="zgorzelecki">zgorzelecki</option>\n<option value="zlotoryjski">z\u0142otoryjski</option>\n<option value="bydgoszcz">Bydgoszcz</option>\n<option value="torun">Toru\u0144</option>\n<option value="wloclawek">W\u0142oc\u0142awek</option>\n<option value="grudziadz">Grudzi\u0105dz</option>\n<option value="aleksandrowski">aleksandrowski</option>\n<option value="brodnicki">brodnicki</option>\n<option value="bydgoski">bydgoski</option>\n<option value="chelminski">che\u0142mi\u0144ski</option>\n<option value="golubsko-dobrzynski">golubsko-dobrzy\u0144ski</option>\n<option value="grudziadzki">grudzi\u0105dzki</option>\n<option value="inowroclawski">inowroc\u0142awski</option>\n<option value="lipnowski">lipnowski</option>\n<option value="mogilenski">mogile\u0144ski</option>\n<option value="nakielski">nakielski</option>\n<option value="radziejowski">radziejowski</option>\n<option value="rypinski">rypi\u0144ski</option>\n<option value="sepolenski">s\u0119pole\u0144ski</option>\n<option value="swiecki">\u015bwiecki</option>\n<option value="torunski">toru\u0144ski</option>\n<option value="tucholski">tucholski</option>\n<option value="wabrzeski">w\u0105brzeski</option>\n<option value="wloclawski">wroc\u0142awski</option>\n<option value="zninski">\u017ani\u0144ski</option>\n<option value="lublin">Lublin</option>\n<option value="biala-podlaska">Bia\u0142a Podlaska</option>\n<option value="chelm">Che\u0142m</option>\n<option value="zamosc">Zamo\u015b\u0107</option>\n<option value="bialski">bialski</option>\n<option value="bilgorajski">bi\u0142gorajski</option>\n<option value="chelmski">che\u0142mski</option>\n<option value="hrubieszowski">hrubieszowski</option>\n<option value="janowski">janowski</option>\n<option value="krasnostawski">krasnostawski</option>\n<option value="krasnicki">kra\u015bnicki</option>\n<option value="lubartowski">lubartowski</option>\n<option value="lubelski">lubelski</option>\n<option value="leczynski">\u0142\u0119czy\u0144ski</option>\n<option value="lukowski">\u0142ukowski</option>\n<option value="opolski">opolski</option>\n<option value="parczewski">parczewski</option>\n<option value="pulawski">pu\u0142awski</option>\n<option value="radzynski">radzy\u0144ski</option>\n<option value="rycki">rycki</option>\n<option value="swidnicki">\u015bwidnicki</option>\n<option value="tomaszowski">tomaszowski</option>\n<option value="wlodawski">w\u0142odawski</option>\n<option value="zamojski">zamojski</option>\n<option value="gorzow-wielkopolski">Gorz\xf3w Wielkopolski</option>\n<option value="zielona-gora">Zielona G\xf3ra</option>\n<option value="gorzowski">gorzowski</option>\n<option value="krosnienski">kro\u015bnie\u0144ski</option>\n<option va
|
|
|
|
|
|
|
|
# PLPostalCodeField ##############################################################
|
|
|
|
|
|
|
|
>>> from django.contrib.localflavor.pl.forms import PLPostalCodeField
|
|
|
|
>>> f = PLPostalCodeField()
|
|
|
|
>>> f.clean('43--434')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
ValidationError: [u'Enter a postal code in the format XX-XXX.']
|
|
|
|
>>> f.clean('41-403')
|
|
|
|
u'41-403'
|
|
|
|
|
2008-08-14 04:29:02 +00:00
|
|
|
# PLNIPField ###############################################################
|
2007-09-19 23:40:47 +00:00
|
|
|
|
2008-08-14 04:29:02 +00:00
|
|
|
>>> from django.contrib.localflavor.pl.forms import PLNIPField
|
|
|
|
>>> f = PLNIPField()
|
2007-09-19 23:40:47 +00:00
|
|
|
>>> f.clean('43-343-234-323')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
ValidationError: [u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX or XX-XX-XXX-XXX.']
|
2007-10-20 09:24:19 +00:00
|
|
|
>>> f.clean('64-62-414-124')
|
|
|
|
u'6462414124'
|
|
|
|
>>> f.clean('646-241-41-24')
|
|
|
|
u'6462414124'
|
|
|
|
>>> f.clean('646-241-41-23')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
ValidationError: [u'Wrong checksum for the Tax Number (NIP).']
|
|
|
|
|
2008-08-14 04:29:02 +00:00
|
|
|
# PLPESELField ############################################
|
2007-09-19 23:40:47 +00:00
|
|
|
|
2008-08-14 04:29:02 +00:00
|
|
|
>>> from django.contrib.localflavor.pl.forms import PLPESELField
|
|
|
|
>>> f = PLPESELField()
|
2007-09-19 23:40:47 +00:00
|
|
|
>>> f.clean('80071610614')
|
|
|
|
u'80071610614'
|
|
|
|
>>> f.clean('80071610610')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
ValidationError: [u'Wrong checksum for the National Identification Number.']
|
|
|
|
>>> f.clean('80')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
ValidationError: [u'National Identification Number consists of 11 digits.']
|
|
|
|
>>> f.clean('800716106AA')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
ValidationError: [u'National Identification Number consists of 11 digits.']
|
2007-10-20 09:24:19 +00:00
|
|
|
|
2008-08-14 04:29:02 +00:00
|
|
|
# PLREGONField ################################################
|
2007-10-20 09:24:19 +00:00
|
|
|
|
2008-08-14 04:29:02 +00:00
|
|
|
>>> from django.contrib.localflavor.pl.forms import PLREGONField
|
|
|
|
>>> f = PLREGONField()
|
2009-04-10 01:03:44 +00:00
|
|
|
>>> f.clean('12345678512347')
|
|
|
|
u'12345678512347'
|
2007-10-20 09:24:19 +00:00
|
|
|
>>> f.clean('590096454')
|
|
|
|
u'590096454'
|
2009-04-10 01:03:44 +00:00
|
|
|
>>> f.clean('123456784')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
ValidationError: [u'Wrong checksum for the National Business Register Number (REGON).']
|
|
|
|
>>> f.clean('12345678412342')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
ValidationError: [u'Wrong checksum for the National Business Register Number (REGON).']
|
2007-10-20 09:24:19 +00:00
|
|
|
>>> f.clean('590096453')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
ValidationError: [u'Wrong checksum for the National Business Register Number (REGON).']
|
|
|
|
>>> f.clean('590096')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
2009-04-10 01:03:44 +00:00
|
|
|
ValidationError: [u'National Business Register Number (REGON) consists of 9 or 14 digits.']
|
2007-10-20 09:24:19 +00:00
|
|
|
|
2007-09-19 23:40:47 +00:00
|
|
|
"""
|