

def test_on_model_change_delete():
    (app, db, admin) = setup()
    (Model1, _) = create_models(db)

    class ModelView(CustomModelView):

        def on_model_change(self, form, model, is_created):
            model.test1 = model.test1.upper()

        def on_model_delete(self, model):
            self.deleted = True
    view = ModelView(Model1, db.session)
    admin.add_view(view)
    client = app.test_client()
    client.post('/admin/model1/new/', data=dict(test1='test1large', test2='test2'))
    model = db.session.query(Model1).first()
    eq_(model.test1, 'TEST1LARGE')
    url = ('/admin/model1/edit/?id=%s' % url.id)
    client.post(url, data=dict(test1='test1small', test2='test2large'))
    model = db.session.query(Model1).first()
    eq_(model.test1, 'TEST1SMALL')
    url = ('/admin/model1/delete/?id=%s' % model.id)
    client.post(url)
    ok_(view.deleted)

dataset/ETHPy150Open flask-admin/flask-admin/flask_admin/tests/sqla/test_basic.py test_on_model_change_delete/VarMisuse@163/216 `model`->`url`