示例#1
0
 def test_given_value_is_exact_size_then_validation_passes(self):
     validator = validators.Length(size=1)
     validator("a")
示例#2
0
 def test_given_value_is_different_from_size_0_then_raises_error(self):
     validator = validators.Length(size=0)
     self.assertRaisesRegexp(ValidationError, "length must be exactly 0",
                             validator, "a")
示例#3
0
 def test_given_value_is_longer_than_maximum_0_then_raises_error(self):
     validator = validators.Length(maximum=0)
     self.assertRaisesRegexp(ValidationError, "maximum length is 0",
                             validator, "a")
示例#4
0
 def test_given_value_is_longer_than_size_then_raises_error(self):
     validator = validators.Length(size=3)
     self.assertRaisesRegexp(ValidationError, "length must be exactly 3",
                             validator, "ab")
示例#5
0
 def test_given_value_is_shorter_than_maximum_then_validation_passes(self):
     validator = validators.Length(maximum=2)
     validator("a")
示例#6
0
 def test_given_value_is_equal_to_maximum_then_validation_passes(self):
     validator = validators.Length(maximum=1)
     validator("a")
示例#7
0
 def test_given_value_is_longer_than_minimum_then_validation_passes(self):
     validator = validators.Length(minimum=1)
     validator("ab")
示例#8
0
 def test_given_value_is_shorter_than_minimum_then_raises_error(self):
     validator = validators.Length(minimum=1)
     self.assertRaisesRegexp(ValidationError, "minimum length is 1",
                             validator, "")
示例#9
0
 def test_given_value_is_none_then_validation_passes(self):
     validator = validators.Length(minimum=1)
     validator(None)