def test_validate(self): field = CepField() field._set_attr_name('d') self.assertIsNone(field.validate('12345678')) self.assertIsNone(field.validate('12345-678')) self.assertIsNone(field.validate('1234567-8')) self.assertEqual('CEP must have exactly 8 characters', field.validate('1234567')) self.assertEqual('CEP must have exactly 8 characters', field.validate('123456789')) self.assertEqual('CEP must contain only numbers', field.validate('1234567a'))
def test_validate(self): field = CepField() field._set_attr_name("d") self.assertIsNone(field.validate("12345678")) self.assertIsNone(field.validate("12345-678")) self.assertIsNone(field.validate("1234567-8")) self.assertEqual("CEP must have exactly 8 characters", field.validate("1234567")) self.assertEqual("CEP must have exactly 8 characters", field.validate("123456789")) self.assertEqual("CEP must contain only numbers", field.validate("1234567a"))
def test_localization(self): field = CepField() self.assertEqual('', field.localize('')) self.assertEqual('', field.localize(None)) self.assertEqual('12345-678', field.localize('12345678'))
def test_normalization(self): field = CepField() self.assertIsNone(field.normalize('')) self.assertIsNone(field.normalize(None)) self.assertEqual('12345678', field.normalize('12345-678')) self.assertEqual('12345678', field.normalize('12345678'))
def test_localization(self): field = CepField() self.assertEqual("", field.localize("")) self.assertEqual("", field.localize(None)) self.assertEqual("12345-678", field.localize("12345678"))
def test_normalization(self): field = CepField() self.assertIsNone(field.normalize("")) self.assertIsNone(field.normalize(None)) self.assertEqual("12345678", field.normalize("12345-678")) self.assertEqual("12345678", field.normalize("12345678"))