from django.contrib.localflavor.it.forms import (ITZipCodeField, ITRegionSelect, ITSocialSecurityNumberField, ITVatNumberField) from utils import LocalFlavorTestCase class ITLocalFlavorTests(LocalFlavorTestCase): def test_ITRegionSelect(self): f = ITRegionSelect() out = u'''''' self.assertEqual(f.render('regions', 'PMN'), out) def test_ITZipCodeField(self): error_invalid = [u'Enter a valid zip code.'] valid = { '00100': '00100', } invalid = { ' 00100': error_invalid, } self.assertFieldOutput(ITZipCodeField, valid, invalid) def test_ITSocialSecurityNumberField(self): error_invalid = [u'Enter a valid Social Security number.'] valid = { 'LVSGDU99T71H501L': 'LVSGDU99T71H501L', 'LBRRME11A01L736W': 'LBRRME11A01L736W', 'lbrrme11a01l736w': 'LBRRME11A01L736W', 'LBR RME 11A01 L736W': 'LBRRME11A01L736W', } invalid = { 'LBRRME11A01L736A': error_invalid, '%BRRME11A01L736W': error_invalid, } self.assertFieldOutput(ITSocialSecurityNumberField, valid, invalid) def test_ITVatNumberField(self): error_invalid = [u'Enter a valid VAT number.'] valid = { '07973780013': '07973780013', '7973780013': '07973780013', 7973780013: '07973780013', } invalid = { '07973780014': error_invalid, 'A7973780013': error_invalid, } self.assertFieldOutput(ITVatNumberField, valid, invalid)