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', '') == []
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}, '') == []
def test_subtype(self): assert ListOfT(IntT()).validate([], '') == [] assert ListOfT(IntT()).validate([1], '') == [] assert ListOfT(TextT()).validate(['foo', 'bar'], '') == []
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)] )
def test_slug(self, test_input): assert TextT(slug=True).validate(test_input, '') == []
def test_non_text(self): assert ( TextT().validate(0, '') == [Result(0, 0, '', 'value is not a valid text value: 0')] )
def test_text(self): assert TextT().validate('', '') == [] assert TextT().validate('foo', '') == []