#NEWLINE# def test_insert_multiple( self ) : #NEWLINE# #INDENT# db = self . db #NEWLINE# db . drop_collection ( 'test' ) #NEWLINE# doc1 = { #NEWLINE# #INDENT# 'hello' : u ( 'world' ) , #NEWLINE# #UNINDENT# } #NEWLINE# doc2 = { #NEWLINE# #INDENT# 'hello' : u ( 'mike' ) , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertEqual ( db . test . find ( ) . count ( ) , 0 ) #NEWLINE# ids = db . test . insert ( [ doc1 , doc2 ] ) #NEWLINE# self . assertEqual ( db . test . find ( ) . count ( ) , 2 ) #NEWLINE# self . assertEqual ( doc1 , db . test . find_one ( { #NEWLINE# #INDENT# 'hello' : u ( 'world' ) , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# self . assertEqual ( doc2 , db . test . find_one ( { #NEWLINE# #INDENT# 'hello' : u ( 'mike' ) , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# self . assertEqual ( 2 , len ( ids ) ) #NEWLINE# self . assertEqual ( doc1 [ '_id' ] , ids [ 0 ] ) #NEWLINE# self . assertEqual ( doc2 [ '_id' ] , ids [ 1 ] ) #NEWLINE# ids = db . test . insert ( [ { #NEWLINE# #INDENT# 'hello' : 1 , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertTrue ( isinstance ( ids , list ) ) #NEWLINE# self . assertEqual ( 1 , len ( ids ) ) #NEWLINE# self . assertRaises ( InvalidOperation , db . test . insert , [ ] ) #NEWLINE# self . assertRaises ( InvalidOperation , db . test . insert , ( i for i in [ ] ) )