Exemple #1
0
 def test_subchildren(self):
     d = {'a': 1, 'b': {'p':12,'q':None}, 'c': {'x':25,'y': 26}}
     schema = sS(SI('a'),SS('b',[SI('p'),SI('q',validator=v.Required())]),SS('c',[SI('x'),SI('y')]))
     w = Wrapper(d, schema)        
     try:
         w.validate()
     except schemaish.Invalid, e:
         assert e.message=='field "b.q" is required'
Exemple #2
0
 def test_sublists(self):
     d = {'a': 1, 'b': {'p':12,'q':13}, 'c': [{'x':25,'y': 26},{'x':None,'y': 26}]}
     schema = sS(SI('a'),SS('b',[SI('p'),SI('q')]),SQ('c',sS(SI('x',validator=v.Required()),SI('y'))))
     w = Wrapper(d, schema)
     try:
         w.validate()
     except schemaish.Invalid, e:
         assert e.message=='field "c.1.x" is required'
Exemple #3
0
 def test_firstchild(self):
     d = {'a': None, 'b': 2, 'c': 3}
     schema = sS(SI('a', validator=v.Required()),SI('b'),SI('c'))
     w = Wrapper(d, schema)
     try:
         w.validate()
     except schemaish.Invalid, e:
         assert e.message=='field "a" is required'