Esempio n. 1
0
 def test_five_digit(self):
     zipcode = uspostcode.validate("66044")
     self.assertEqual('66044', zipcode)
     try:
         zipcode = uspostcode.validate(" 66044 ")
         self.fail("Invalid postal code not caught")
     except:
         pass
Esempio n. 2
0
 def test_nine_digit(self):
     zipcode = uspostcode.validate("94043-1351")
     self.assertEqual('94043-1351', zipcode)
     try:
         zipcode = uspostcode.validate(" 94043-1351 ")
         self.fail('Invalide postal code not caught')
     except:
         pass
Esempio n. 3
0
 def test_nine_digit(self):
     zipcode = uspostcode.validate("94043-1351")
     self.assertEqual('94043-1351', zipcode)
     try:
         zipcode = uspostcode.validate(" 94043-1351 ")
         self.fail('Invalide postal code not caught')
     except:
         pass
Esempio n. 4
0
 def test_five_digit(self):
     zipcode = uspostcode.validate("66044")
     self.assertEqual('66044', zipcode)
     try:
         zipcode = uspostcode.validate(" 66044 ")
         self.fail("Invalid postal code not caught")
     except:
         pass
Esempio n. 5
0
    def test_invalid(self):
        try:
            code = uspostcode.validate("")
            self.fail('Invalid blank postal code not caught')
        except:
            pass

        try:
            zipcode = uspostcode.validate("no")
            self.fail('Invalid ZIP code "no" not caught')
        except:
            pass
Esempio n. 6
0
 def test_invalid(self):
     try:
         code = uspostcode.validate("")
         self.fail('Invalid blank postal code not caught')
     except:
         pass
     
     try:
         zipcode = uspostcode.validate("no")
         self.fail('Invalid ZIP code "no" not caught')
     except:
         pass
Esempio n. 7
0
def us_postcode_validator(sender, postcode=None, country=None, **kwargs):
    if country.iso2_code == 'US':
        from satchmo.l10n.validators import uspostcode
        try:
            pc = uspostcode.validate(postcode)
            return pc
        except ValueError, ve:
            raise forms.ValidationError('Please enter a valid US ZIP code.')
Esempio n. 8
0
def us_postcode_validator(sender, postcode=None, country=None, **kwargs):
    if country.iso2_code == 'US':
        from satchmo.l10n.validators import uspostcode
        try:
            pc = uspostcode.validate(postcode)
            return pc
        except ValueError, ve:
            raise forms.ValidationError('Please enter a valid US ZIP code.')