def test_mockview():
    app, admin = setup()

    view = MockModelView(Model)
    admin.add_view(view)

    eq_(view.model, Model)

    eq_(view.name, 'Model')
    eq_(view.url, '/admin/model')
    eq_(view.endpoint, 'model')
    ok_(view.blueprint is not None)

    client = app.test_client()

    # Make model view requests
    rv = client.get('/admin/model/')
    eq_(rv.status_code, 200)

    # Test model creation view
    rv = client.get('/admin/model/add/')
    eq_(rv.status_code, 200)

    rv = client.post('/admin/model/add/',
                     data=dict(col1='test1', col2='test2', col3='test3'))
    eq_(rv.status_code, 302)
    eq_(len(view.created_models), 1)

    model = view.created_models.pop()
    eq_(model.id, 3)
    eq_(model.col1, 'test1')
    eq_(model.col2, 'test2')
    eq_(model.col3, 'test3')

    # Try model edit view
    rv = client.get('/admin/model/3/')
    eq_(rv.status_code, 200)
    ok_(rv.data in 'test1')

    rv = client.post('/admin/model/3/',
                     data=dict(col1='test!', col2='test@', col3='test#'))
    eq_(rv.status_code, 302)
    eq_(len(view.updated_models), 1)

    model = view.updated_models.pop()
    eq_(model.col1, 'test!')
    eq_(model.col2, 'test@')
    eq_(model.col3, 'test#')

    rv = client.get('/admin/modelview/4/')
    eq_(rv.status_code, 404)

    # Attempt to delete model
    rv = client.post('/admin/model/3/delete/', data=dict(confirm_delete=True))
    eq_(rv.status_code, 302)
    eq_(rv.headers['location'], 'http://localhost/admin/model/')
dataset/ETHPy150Open syrusakbary/Flask-SuperAdmin/flask_superadmin/tests/test_model.py/test_mockview/swapped operands of `in`