How to use the colander.tests.DummySchemaNode function in colander

To help you get started, we’ve selected a few colander examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pylons / colander / colander / tests.py View on Github external
def test_deserialize_not_iterable(self):
        node = DummySchemaNode(None)
        typ = self._makeOne()
        e = invalid_exc(typ.deserialize, node, None)
        self.assertEqual(
            e.msg.interpolate(),
            '"None" is not iterable')
        self.assertEqual(e.node, node)
github Pylons / colander / colander / tests.py View on Github external
def test_deserialize_toobig(self):
        node = DummySchemaNode(None)
        node.children = [DummySchemaNode(None, name='a')]
        typ = self._makeOne()
        e = invalid_exc(typ.deserialize, node, ('a','b'))
        self.assertEqual(e.msg.interpolate(),
      "\"('a', 'b')\" has an incorrect number of elements (expected 1, was 2)")
github Pylons / colander / colander / tests.py View on Github external
def test_serialize_subnodes_raise(self):
        node = DummySchemaNode(None)
        node.children = [
            DummySchemaNode(None, name='a', exc='Wrong 2'),
            DummySchemaNode(None, name='b', exc='Wrong 2'),
            ]
        typ = self._makeOne()
        e = invalid_exc(typ.serialize, node, ('1', '2'))
        self.assertEqual(e.msg, None)
        self.assertEqual(len(e.children), 2)
github Pylons / colander / colander / tests.py View on Github external
def test__zope_dottedname_style_resolve_relative_leading_dots(self):
        import colander
        typ = self._makeOne(package=colander.tests)
        node = DummySchemaNode(None)
        result = typ._zope_dottedname_style(node, '..tests.TestGlobalObject')
        self.assertEqual(result, self.__class__)
github Pylons / colander / colander / tests.py View on Github external
def test_serialize_toosmall(self):
        node = DummySchemaNode(None)
        node.children = [DummySchemaNode(None, name='a')]
        typ = self._makeOne()
        e = invalid_exc(typ.serialize, node, ())
        self.assertEqual(e.msg.interpolate(),
           '"()" has an incorrect number of elements (expected 1, was 0)'
           )
github Pylons / colander / colander / tests.py View on Github external
def test_deserialize_toosmall(self):
        node = DummySchemaNode(None)
        node.children = [DummySchemaNode(None, name='a')]
        typ = self._makeOne()
        e = invalid_exc(typ.deserialize, node, ())
        self.assertEqual(e.msg.interpolate(),
           '"()" has an incorrect number of elements (expected 1, was 0)')
github Pylons / colander / colander / tests.py View on Github external
def test_unflatten_nested(self):
        node = DummySchemaNode(None, name='node')
        inttype = DummyType()
        one = DummySchemaNode(self._makeOne(), name='one')
        one.children = [
            DummySchemaNode(inttype, name='a'),
            DummySchemaNode(inttype, name='b'),
        ]
        two = DummySchemaNode(self._makeOne(), name='two')
        two.children = [
            DummySchemaNode(inttype, name='c'),
            DummySchemaNode(inttype, name='d'),
        ]
        node.children = [one, two]
        typ = self._makeOne()
        result = typ.unflatten(
            node, ['node', 'node.one', 'node.one.a', 'node.one.b',
                   'node.two', 'node.two.c', 'node.two.d'],
github Pylons / colander / colander / tests.py View on Github external
def test_setvalue(self):
        typ = self._makeOne()
        node1 = DummySchemaNode(typ, name='seq1')
        node2 = DummySchemaNode(typ, name='seq2')
        node1.children = [node2]
        node2.children = DummySchemaNode(None, name='items')
        appstruct = [[1, 2], [3, 4]]
        typ.set_value(node1, appstruct, '1.0', 34)
        self.assertEqual(appstruct, [[1, 2], [34, 4]])
github Pylons / colander / colander / tests.py View on Github external
def test_get_value_bad_path(self):
        typ = self._makeOne()
        node = DummySchemaNode(typ, name='node')
        node.children = [
            DummySchemaNode(None, name='foo'),
            DummySchemaNode(None, name='bar')
        ]
        self.assertRaises(
            KeyError, typ.get_value, node, (1, 2), 'foobar')
github Pylons / colander / colander / tests.py View on Github external
def test_flatten_listitem(self):
        node = DummySchemaNode(None, name='node')
        int1 = DummyType()
        int2 = DummyType()
        node.children = [
            DummySchemaNode(int1, name='a'),
            DummySchemaNode(int2, name='b'),
            ]
        typ = self._makeOne()
        result = typ.flatten(node, {'a':1, 'b':2}, listitem=True)
        self.assertEqual(result, {'appstruct': 2})