#NEWLINE# def _test_fts_auto( self , ModelClass ) : #NEWLINE# #INDENT# posts = [ ] #NEWLINE# for message in self . messages : #NEWLINE# #INDENT# posts . append ( Post . create ( message = ModelClass ) ) #NEWLINE# #UNINDENT# pq = ModelClass . select ( ) . where ( ModelClass . match ( 'faith' ) ) #NEWLINE# self . assertEqual ( list ( pq ) , [ ] ) #NEWLINE# ModelClass . rebuild ( ) #NEWLINE# ModelClass . optimize ( ) #NEWLINE# pq = ModelClass . select ( ) . where ( ModelClass . match ( 'faith' ) ) . order_by ( ModelClass . docid ) #NEWLINE# self . assertMessages ( pq , range ( len ( self . messages ) ) ) #NEWLINE# pq = ModelClass . select ( ) . where ( ModelClass . match ( 'believe' ) ) . order_by ( ModelClass . docid ) #NEWLINE# self . assertMessages ( pq , [ 0 , 3 ] ) #NEWLINE# pq = ModelClass . select ( ) . where ( ModelClass . match ( 'thin*' ) ) . order_by ( ModelClass . docid ) #NEWLINE# self . assertMessages ( pq , [ 2 , 4 ] ) #NEWLINE# pq = ModelClass . select ( ) . where ( ModelClass . match ( '"it is"' ) ) . order_by ( ModelClass . docid ) #NEWLINE# self . assertMessages ( pq , [ 2 , 3 ] ) #NEWLINE# pq = ModelClass . search ( 'things' , with_score = True ) #NEWLINE# self . assertEqual ( [ ( x . message , x . score ) for x in pq ] , [ ( self . messages [ 4 ] , ( ( - 2.0 ) / 3 ) ) , ( self . messages [ 2 ] , ( ( - 1.0 ) / 3 ) ) ] ) #NEWLINE# pq = ModelClass . select ( ModelClass . rank ( ) ) . where ( ModelClass . match ( 'faithful' ) ) . tuples ( ) #NEWLINE# self . assertEqual ( [ x [ 0 ] for x in pq ] , ( [ ( - 0.2 ) ] * 5 ) ) #NEWLINE# pq = ModelClass . search ( 'faithful' , with_score = True ) . dicts ( ) #NEWLINE# self . assertEqual ( [ x [ 'score' ] for x in pq ] , ( [ ( - 0.2 ) ] * 5 ) )