예제 #1
0
    def test_clone_from_class(self):
        parent = Model(
            'Parent', {
                'name': fields.String,
                'age': fields.Integer,
                'birthdate': fields.DateTime,
            })

        child = Model.clone('Child', parent, {
            'extra': fields.String,
        })

        assert child.__schema__ == {
            'properties': {
                'name': {
                    'type': 'string'
                },
                'age': {
                    'type': 'integer'
                },
                'birthdate': {
                    'type': 'string',
                    'format': 'date-time'
                },
                'extra': {
                    'type': 'string'
                }
            },
            'type': 'object'
        }
예제 #2
0
    def test_clone_from_instance_with_multiple_parents(self):
        grand_parent = Model('GrandParent', {
            'grand_parent': fields.String,
        })

        parent = Model(
            'Parent', {
                'name': fields.String,
                'age': fields.Integer,
                'birthdate': fields.DateTime,
            })

        child = grand_parent.clone('Child', parent, {
            'extra': fields.String,
        })

        assert child.__schema__ == {
            'properties': {
                'grand_parent': {
                    'type': 'string'
                },
                'name': {
                    'type': 'string'
                },
                'age': {
                    'type': 'integer'
                },
                'birthdate': {
                    'type': 'string',
                    'format': 'date-time'
                },
                'extra': {
                    'type': 'string'
                }
            },
            'type': 'object'
        }