예제 #1
0
 def test_max(self):
     field = String(max=3)
     field.data = field.convert(["test"])
     assert field.data == "test"
     assert not field.validate()
     assert field.errors == ["Must be at most 3 characters."]
예제 #2
0
 def test_min(self):
     field = String(min=5)
     field.data = field.convert(["test"])
     assert field.data == "test"
     assert not field.validate()
     assert field.errors == ["Must be at least 5 characters."]
예제 #3
0
 def test_none_required(self):
     field = String()
     field.data = field.convert(None)
     assert field.data is None
     assert not field.validate()
     assert field.errors == ["Required."]
예제 #4
0
 def test_none_default(self):
     field = String(default="test")
     field.data = field.convert(None)
     assert field.data == "test"
     assert field.validate()
     assert field.errors == []
예제 #5
0
 def test_none(self):
     field = String(required=False)
     field.data = field.convert(None)
     assert field.data is None
     assert field.validate()
     assert field.errors == []
예제 #6
0
 def test_basic(self):
     field = String()
     field.data = field.convert(["test"])
     assert field.data == "test"
     assert field.validate()
     assert field.errors == []