Пример #1
0
 def test_str_exactly_len_chars(self):
     field = StringField(exactly_len=10)
     field._set_attr_name('n')
     self.assertEqual('Has 11 characters and it must have exactly 10', field.validate_field('a' * 11))
     self.assertEqual('Has 9 characters and it must have exactly 10', field.validate_field('a' * 9))
     self.assertIsNone(field.validate_field('a' * 10))
Пример #2
0
 def test_str_max_len_chars(self):
     field = StringField(max_len=10)
     field._set_attr_name('n')
     self.assertEqual('Has 11 characters and it must have 10 or less', field.validate_field('a' * 11))
Пример #3
0
 def test_str_min_len_chars(self):
     field = StringField(min_len=2)
     field._set_attr_name('n')
     self.assertEqual('Has 1 characters and it must have 2 or more', field.validate_field('a'))
     self.assertIsNone(field.validate_field('aa'))
     self.assertIsNone(field.validate_field('aaa'))
Пример #4
0
 def test_str_with_more_than_500_chars(self):
     field = StringField()
     field._set_attr_name('n')
     self.assertEqual('Has 1501 characters and it must have 1500 or less', field.validate_field('a' * (base._MAX_STRING_LENGTH+1)))