def test_complex_searchable_list():
    app, db, admin = setup()

    Model1, Model2 = create_models(db)

    view = CustomModelView(Model2, db.session,
                           column_searchable_list=['model1.test1'])
    admin.add_view(view)

    m1 = Model1('model1-test1-val')
    m2 = Model1('model1-test2-val')
    db.session.add(m1)
    db.session.add(m2)
    db.session.add(Model2('model2-test1-val', model1=m1))
    db.session.add(Model2('model2-test2-val', model1=m2))
    db.session.commit()

    client = app.test_client()

    # test relation string - 'model1.test1'
    rv = client.get('/admin/model2/?search=model1-test1')
    data = rv.data.decode('utf-8')
    ok_('model2-test1-val' in data)
    ok_('model2-test2-val' not in data)

    view2 = CustomModelView(Model1, db.session,
                           column_searchable_list=[Model2.string_field])
    admin.add_view(view2)

    # test relation object - Model2.string_field
    rv = client.get('/admin/model1/?search=model2-test1')
    data = rv.data.decode('utf-8')
    ok_('model1-test1-val' in data)
    ok_('model1-test2-val' not in data)
dataset/ETHPy150Open flask-admin/flask-admin/flask_admin/tests/sqla/test_basic.py/test_complex_searchable_list/original