def test__validate_source_is_ICSB_bound(self):
from zope.interface import implementer
from guillotina.schema.interfaces import IContextSourceBinder
from guillotina.schema.exceptions import ConstraintNotSatisfied
from guillotina.schema.tests.test_vocabulary import _makeSampleVocabulary
@implementer(IContextSourceBinder)
class SampleContextSourceBinder(object):
def __call__(self, context):
return _makeSampleVocabulary()
s = SampleContextSourceBinder()
choice = self._makeOne(source=s)
# raises not iterable with unbound field
self.assertRaises(TypeError, choice.validate, 1)
o = object()
clone = choice.bind(o)
clone._validate(1)
clone._validate(3)
self.assertRaises(ConstraintNotSatisfied, clone._validate, 42)
评论列表
文章目录