def test_simple_validator(self): # Create contract trafaret = t.Trafaret() template = Template(trafaret) contract = Contract(template) self.assertEqual(contract.template, template) new_template = Template(trafaret) contract.template = new_template self.assertEqual(contract.template, new_template) # Int int_t = Template(t.Int()) contract = Contract(int_t) # String string_t = Template(t.String()) contract = Contract(string_t) # Dict dict_t = Template(t.Dict({'id': t.Int, 'email': t.Email})) contract.template = dict_t # List list_t = Template(t.List(t.Int)) contract.template = list_t
def test_any(self): obj = {} trafaret = t.Trafaret() with pytest.raises(NotImplementedError): assert trafaret.check(obj) == obj assert trafaret.is_valid(obj)