class TestElement(elements.Element): schema = [ elements.Leaf(type=str), { 'test': TestChild } ]
class TestChild(elements.Element): schema = elements.Leaf(type=str) requires = { 'self': [requirements.Value( 'req', multiple_results=True, predicate=predicate)] }
def test_invalid_dict_schema(self): def assertion(schema): test_element = type('TestElement', (elements.Element, ), {'schema': schema}) self.assert_invalid(test_element) class TestLeaf(elements.Element): schema = elements.Leaf(type=text_type) assertion({1: TestLeaf}) assertion({'key': elements.Leaf(type=text_type)}) assertion({'key': None}) assertion({'key': 'str'}) assertion({'key': elements.Element})
class ChildElement(elements.Element): schema = elements.Leaf(type=text_type) def parse(self): return self.ancestor(TestElement).value
class TestLeaf(elements.Element): schema = elements.Leaf(type=text_type)
class TestElement(elements.Element): required = True schema = elements.Leaf(type=text_type)
class TestChild(elements.Element): schema = elements.Leaf(type=int)
class TestChildElement(elements.Element): schema = elements.Leaf(type=text_type)
class TestDictValue(elements.Element): schema = elements.Leaf(type=text_type)
class TestLeaf1(elements.Element): schema = elements.Leaf(type=(str, bool, list))
class TestListLeaf(elements.Element): schema = elements.Leaf(type=list)
class TestDictLeaf(elements.Element): schema = elements.Leaf(type=dict)
class TestList(elements.Element): schema = [elements.Leaf(type=text_type), [elements.Leaf(type=int)]]
class TestLeaf(elements.Element): schema = elements.Leaf(type=str)
class TestElement(elements.Element): schema = elements.Leaf(type=(1, ))
class TestLeaf2(elements.Element): schema = elements.Leaf(type=[str, bool, list])
class TestList(elements.Element): schema = [ elements.Leaf(type=str), [elements.Leaf(type=int)] ]