#NEWLINE# def test_column_searchable_list( ) : #NEWLINE# #INDENT# ( app , db , admin ) = setup ( ) #NEWLINE# ( Model1 , Model2 ) = create_models ( db ) #NEWLINE# view = CustomModelView ( Model2 , db . session , column_searchable_list = [ 'string_field' , 'int_field' ] ) #NEWLINE# admin . add_view ( view ) #NEWLINE# eq_ ( view . _search_supported , True ) #NEWLINE# eq_ ( len ( view . _search_fields ) , 2 ) #NEWLINE# ok_ ( isinstance ( view . _search_fields [ 0 ] , db . Column ) ) #NEWLINE# ok_ ( isinstance ( view . _search_fields [ 1 ] , db . Column ) ) #NEWLINE# eq_ ( view . _search_fields [ 0 ] . name , 'string_field' ) #NEWLINE# eq_ ( view . _search_fields [ 1 ] . name , 'int_field' ) #NEWLINE# db . session . add ( Model2 ( 'model1-test' , 5000 ) ) #NEWLINE# db . session . add ( Model2 ( 'model2-test' , 9000 ) ) #NEWLINE# db . session . commit ( ) #NEWLINE# client = app . test_client ( ) #NEWLINE# rv = client . get ( '/admin/model2/?search=model1' ) #NEWLINE# data = rv . data . decode ( 'utf-8' ) #NEWLINE# ok_ ( ( 'model1-test' in data ) ) #NEWLINE# ok_ ( ( 'model2-test' not in data ) ) #NEWLINE# rv = client . get ( '/admin/model2/?search=9000' ) #NEWLINE# data = rv . data . decode ( 'utf-8' ) #NEWLINE# ok_ ( ( 'model1-test' not in data ) ) #NEWLINE# ok_ ( ( 'model2-test' in data ) )