#NEWLINE# def test_close_when_not_closed( self ) : #NEWLINE# #INDENT# writer = mock ( ) #NEWLINE# expect ( mock ( channel_class , 'Writer' ) ) . returns ( writer ) #NEWLINE# expect ( writer . write_short ) . args ( 'rcode' ) #NEWLINE# expect ( writer . write_shortstr ) . args ( ( 'reason' * 60 ) [ : 255 ] ) #NEWLINE# expect ( writer . write_short ) . args ( 'cid' ) #NEWLINE# expect ( writer . write_short ) . args ( 'mid' ) #NEWLINE# expect ( mock ( channel_class , 'MethodFrame' ) ) . args ( 42 , 20 , 40 , writer ) . returns ( 'frame' ) #NEWLINE# expect ( self . klass . send_frame ) . args ( 'frame' ) #NEWLINE# expect ( self . klass . channel . add_synchronous_cb ) . args ( self . klass . _recv_close_ok ) #NEWLINE# self . klass . close ( 'rcode' , ( 'reason' * 60 ) , 'cid' , 'mid' ) #NEWLINE# assert_true ( self . klass . channel . _closed ) #NEWLINE# assert_equals ( { #NEWLINE# #INDENT# 'reply_code' : 'rcode' , #NEWLINE# 'reply_text' : ( 'reason' * 60 ) , #NEWLINE# 'class_id' : 'cid' , #NEWLINE# 'method_id' : 'mid' , #NEWLINE# #UNINDENT# } , self . klass . channel . _close_info )