Пример #1
0
    def test_make_schema(self):
        import sqlalchemy2deform

        M = self._makeModel()
        S = self._makeSchema()

        myschema = S()
        schema = sqlalchemy2deform.make_schema(M)

        myschema_nodes = myschema.children
        for i, node in enumerate(schema):
            self.assertEqual(node.typ.__class__,
                    myschema_nodes[i].typ.__class__)
            self.assertEqual(node.required, myschema_nodes[i].required)

        self.assertEqual(schema.typ.__class__, myschema.typ.__class__)
Пример #2
0
    def test_make_schema_with_columns(self):
        import sqlalchemy2deform

        columns = ['unicode_column', 'datetime_column']

        M = self._makeModel()
        S = self._makeSchema(columns)

        myschema = S()
        schema = sqlalchemy2deform.make_schema(M, columns)

        myschema_nodes = myschema.children
        for i, node in enumerate(schema):
            self.assertEqual(node.typ.__class__,
                    myschema_nodes[i].typ.__class__)
            self.assertEqual(node.required, myschema_nodes[i].required)

        self.assertEqual(schema.typ.__class__, myschema.typ.__class__)
Пример #3
0
    def test_make_schema_with_widget(self):
        import deform
        import sqlalchemy2deform

        M = self._makeModel()
        S = self._makeSchema()
        W = {'datetime_column': deform.widget.TextInputWidget}

        myschema = S()
        schema = sqlalchemy2deform.make_schema(M, widgets=W)

        myschema_nodes = myschema.children
        for i, node in enumerate(schema):
            self.assertEqual(node.typ.__class__,
                    myschema_nodes[i].typ.__class__)
            self.assertEqual(node.required, myschema_nodes[i].required)
            widget = W.get(node.name)
            if (widget):
                self.assertEqual(node.widget, widget)

        self.assertEqual(schema.typ.__class__, myschema.typ.__class__)