parts/django/tests/regressiontests/forms/localflavor/it.py
changeset 307 c6bca38c1cbf
equal deleted inserted replaced
306:5ff1fc726848 307:c6bca38c1cbf
       
     1 from django.contrib.localflavor.it.forms import (ITZipCodeField, ITRegionSelect,
       
     2     ITSocialSecurityNumberField, ITVatNumberField)
       
     3 
       
     4 from utils import LocalFlavorTestCase
       
     5 
       
     6 
       
     7 class ITLocalFlavorTests(LocalFlavorTestCase):
       
     8     def test_ITRegionSelect(self):
       
     9         f = ITRegionSelect()
       
    10         out = u'''<select name="regions">
       
    11 <option value="ABR">Abruzzo</option>
       
    12 <option value="BAS">Basilicata</option>
       
    13 <option value="CAL">Calabria</option>
       
    14 <option value="CAM">Campania</option>
       
    15 <option value="EMR">Emilia-Romagna</option>
       
    16 <option value="FVG">Friuli-Venezia Giulia</option>
       
    17 <option value="LAZ">Lazio</option>
       
    18 <option value="LIG">Liguria</option>
       
    19 <option value="LOM">Lombardia</option>
       
    20 <option value="MAR">Marche</option>
       
    21 <option value="MOL">Molise</option>
       
    22 <option value="PMN" selected="selected">Piemonte</option>
       
    23 <option value="PUG">Puglia</option>
       
    24 <option value="SAR">Sardegna</option>
       
    25 <option value="SIC">Sicilia</option>
       
    26 <option value="TOS">Toscana</option>
       
    27 <option value="TAA">Trentino-Alto Adige</option>
       
    28 <option value="UMB">Umbria</option>
       
    29 <option value="VAO">Valle d\u2019Aosta</option>
       
    30 <option value="VEN">Veneto</option>
       
    31 </select>'''
       
    32         self.assertEqual(f.render('regions', 'PMN'), out)
       
    33 
       
    34     def test_ITZipCodeField(self):
       
    35         error_invalid = [u'Enter a valid zip code.']
       
    36         valid = {
       
    37             '00100': '00100',
       
    38         }
       
    39         invalid = {
       
    40             ' 00100': error_invalid,
       
    41         }
       
    42         self.assertFieldOutput(ITZipCodeField, valid, invalid)
       
    43     
       
    44     def test_ITSocialSecurityNumberField(self):
       
    45         error_invalid = [u'Enter a valid Social Security number.']
       
    46         valid = {
       
    47             'LVSGDU99T71H501L': 'LVSGDU99T71H501L',
       
    48             'LBRRME11A01L736W': 'LBRRME11A01L736W',
       
    49             'lbrrme11a01l736w': 'LBRRME11A01L736W',
       
    50             'LBR RME 11A01 L736W': 'LBRRME11A01L736W',
       
    51         }
       
    52         invalid = {
       
    53             'LBRRME11A01L736A': error_invalid,
       
    54             '%BRRME11A01L736W': error_invalid,
       
    55         }
       
    56         self.assertFieldOutput(ITSocialSecurityNumberField, valid, invalid)
       
    57     
       
    58     def test_ITVatNumberField(self):
       
    59         error_invalid = [u'Enter a valid VAT number.']
       
    60         valid = {
       
    61             '07973780013': '07973780013',
       
    62             '7973780013': '07973780013',
       
    63             7973780013: '07973780013',
       
    64         }
       
    65         invalid = {
       
    66             '07973780014': error_invalid,
       
    67             'A7973780013': error_invalid,
       
    68         }
       
    69         self.assertFieldOutput(ITVatNumberField, valid, invalid)
       
    70