Beispiel #1
0
 def test_required(self):
     assert (
         TextT(required=True).validate(None, '') ==
         [Result(0, 0, '', 'value required')]
     )
     assert TextT(required=True).validate('', '') == []
     assert TextT(required=True).validate('foo', '') == []
Beispiel #2
0
 def test_subtype(self):
     assert DictOfT({'foo': IntT()}).validate({'foo': 5}, '') == []
     assert DictOfT({'foo': TextT()}).validate({'foo': 'bar'}, '') == []
     assert DictOfT({'foo': TextT(), 'bar': IntT()}).validate({'foo': 'val1', 'bar': 5}, '') == []
Beispiel #3
0
 def test_subtype(self):
     assert ListOfT(IntT()).validate([], '') == []
     assert ListOfT(IntT()).validate([1], '') == []
     assert ListOfT(TextT()).validate(['foo', 'bar'], '') == []
Beispiel #4
0
 def test_non_slug(self, test_input):
     assert (
         TextT(slug=True).validate(test_input, '') ==
         [Result(0, 0, '', 'value is not a valid slug: %r' % test_input)]
     )
Beispiel #5
0
 def test_slug(self, test_input):
     assert TextT(slug=True).validate(test_input, '') == []
Beispiel #6
0
 def test_non_text(self):
     assert (
         TextT().validate(0, '') ==
         [Result(0, 0, '', 'value is not a valid text value: 0')]
     )
Beispiel #7
0
 def test_text(self):
     assert TextT().validate('', '') == []
     assert TextT().validate('foo', '') == []