

def test_default_complex_sort():
    (app, db, admin) = setup()
    (M1, M2) = create_models(db)
    m1 = M1('b')
    db.session.add(m1)
    db.session.add(M2('c', model1=m1))
    m2 = M1('a')
    db.session.add(m2)
    db.session.add(M2('c', model1=m2))
    db.session.commit()
    view = CustomModelView(M2, db.session, column_default_sort='model1.test1')
    admin.add_view(view)
    (_, data) = view.get_list(0, None, None, None, None)
    eq_(len(data), 2)
    eq_(data[0].model1.test1, 'a')
    eq_(data[1].model1.test1, 'b')
    view2 = CustomModelView(M2, db.session, endpoint='model2_2', column_default_sort=(M1.test1, False))
    admin.add_view(view2)
    (_, data) = view2.get_list(0, None, None, None, None)
    eq_(len(data), 2)
    eq_(data[0].model1.test1, 'a')
    eq_(data[1].model1.test1, 'b')

dataset/ETHPy150Open flask-admin/flask-admin/flask_admin/tests/sqla/test_basic.py test_default_complex_sort/original