#NEWLINE# def test_find_options( self ) : #NEWLINE# #INDENT# cmd = SON ( [ ( 'find' , 'test' ) , ( 'filter' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) , ( 'comment' , 'this is a test' ) , ( 'sort' , SON ( [ ( '_id' , 1 ) ] ) ) , ( 'projection' , { #NEWLINE# #INDENT# 'x' : False , #NEWLINE# #UNINDENT# } ) , ( 'skip' , 1 ) , ( 'batchSize' , 2 ) , ( 'noCursorTimeout' , True ) , ( 'allowPartialResults' , True ) ] ) #NEWLINE# self . client . pymongo_test . test . drop ( ) #NEWLINE# self . client . pymongo_test . test . insert_many ( [ { #NEWLINE# #INDENT# 'x' : i , #NEWLINE# #UNINDENT# } for i in range ( 5 ) ] ) #NEWLINE# self . listener . results . clear ( ) #NEWLINE# coll = self . client . pymongo_test . test #NEWLINE# if ( self . client . is_mongos and client_context . version . at_least ( 2 , 4 , 0 ) ) : #NEWLINE# #INDENT# coll = coll . with_options ( read_preference = ReadPreference . PRIMARY_PREFERRED ) #NEWLINE# #UNINDENT# cursor = coll . find ( filter = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , projection = { #NEWLINE# #INDENT# 'x' : False , #NEWLINE# #UNINDENT# } , skip = 1 , no_cursor_timeout = True , sort = [ ( '_id' , 1 ) ] , allow_partial_results = True , modifiers = SON ( [ ( '$comment' , 'this is a test' ) ] ) , batch_size = 2 ) #NEWLINE# next ( cursor ) #NEWLINE# try : #NEWLINE# #INDENT# results = self . listener . results #NEWLINE# started = results [ 'started' ] [ 0 ] #NEWLINE# succeeded = results [ 'succeeded' ] [ 0 ] #NEWLINE# self . assertEqual ( 0 , len ( results [ 'failed' ] ) ) #NEWLINE# self . assertTrue ( isinstance ( started , monitoring . CommandStartedEvent ) ) #NEWLINE# self . assertEqual ( cmd , started . command ) #NEWLINE# self . assertEqual ( 'find' , started . command_name ) #NEWLINE# self . assertEqual ( self . client . address , started . connection_id ) #NEWLINE# self . assertEqual ( 'pymongo_test' , started . database_name ) #NEWLINE# self . assertTrue ( isinstance ( started . request_id , int ) ) #NEWLINE# self . assertTrue ( isinstance ( succeeded , monitoring . CommandSucceededEvent ) ) #NEWLINE# self . assertTrue ( isinstance ( succeeded . duration_micros , int ) ) #NEWLINE# self . assertEqual ( 'find' , succeeded . command_name ) #NEWLINE# self . assertTrue ( isinstance ( succeeded . request_id , int ) ) #NEWLINE# self . assertEqual ( self . client . address , succeeded . connection_id ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# tuple ( cursor )