#NEWLINE# def test_init( self ) : #NEWLINE# #INDENT# conn = Accumulo ( _connect = False ) #NEWLINE# conn . client = Mock ( ) #NEWLINE# conn . client . createWriter = Mock ( return_value = 'writer1' ) #NEWLINE# conn . login = 'Login' #NEWLINE# b = BatchWriter ( conn = conn , table = 'mytable' , max_memory = 10 , latency_ms = 30 , timeout_ms = 5 , threads = 11 ) #NEWLINE# conn . client . createWriter . assert_called_with ( 'Login' , 'mytable' , WriterOptions ( maxMemory = 10 , latencyMs = 30 , timeoutMs = 5 , threads = 11 ) ) #NEWLINE# conn . client . update = Mock ( ) #NEWLINE# b . _writer = 'writer1' #NEWLINE# mut = Mock ( row = 'r01' , updates = [ 'x' , 'y' , 'z' ] ) #NEWLINE# b . add_mutation ( mut ) #NEWLINE# conn . client . update . assert_called_with ( 'writer1' , { #NEWLINE# #INDENT# 'r01' : [ 'x' , 'y' , 'z' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# conn . client . update = Mock ( ) #NEWLINE# b . _writer = 'writer1' #NEWLINE# mut1 = Mock ( row = 'r01' , updates = [ 'x' , 'y' , 'z' ] ) #NEWLINE# mut2 = Mock ( row = 'r02' , updates = [ 'a' , 'b' , 'c' ] ) #NEWLINE# b . add_mutations ( [ mut1 , mut2 ] ) #NEWLINE# conn . client . update . assert_called_with ( 'writer1' , { #NEWLINE# #INDENT# 'r01' : [ 'x' , 'y' , 'z' ] , #NEWLINE# 'r02' : [ 'a' , 'b' , 'c' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# conn . client . flush = Mock ( ) #NEWLINE# b . flush ( ) #NEWLINE# conn . client . flush . assert_called_with ( 'writer1' ) #NEWLINE# conn . client . closeWriter = Mock ( ) #NEWLINE# b . close ( ) #NEWLINE# conn . client . closeWriter . assert_called_with ( 'writer1' ) #NEWLINE# self . assertTrue ( b . _is_closed ) #NEWLINE# with self . assertRaises ( Exception ) : #NEWLINE# #INDENT# b . add_mutation ( mut ) #NEWLINE# #UNINDENT# with self . assertRaises ( Exception ) : #NEWLINE# #INDENT# b . add_mutations ( [ mut1 , mut2 ] ) #NEWLINE# #UNINDENT# with self . assertRaises ( Exception ) : #NEWLINE# #INDENT# b . flush ( )