#NEWLINE# def test_regular_call( self ) : #NEWLINE# #INDENT# '\n        This test simulates situation when the peer is already connected.\n        ' #NEWLINE# self . client . connected = mock . Mock ( ) #NEWLINE# self . client . connected . get = mock . Mock ( side_effect = ( lambda ident : True ) ) #NEWLINE# self . client . send_params = mock . Mock ( ) #NEWLINE# req_id = b'some id' #NEWLINE# params = defaultdict ( ( lambda : None ) , req_id = req_id , command = 'call' ) #NEWLINE# result = { #NEWLINE# #INDENT# 'req_id' : req_id , #NEWLINE# 'return' : 'x' , #NEWLINE# 'exception' : TestException ( ) , #NEWLINE# 'exception_format' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# def wait( exc ) : #NEWLINE# #INDENT# self . assertEqual ( exc , snakemq . rpc . PartialCall ) #NEWLINE# self . client . store_result ( result ) #NEWLINE# #UNINDENT# with mock . patch . object ( snakemq . rpc . Wait , '__call__' ) as wait_mock : #NEWLINE# #INDENT# wait_mock . side_effect = wait #NEWLINE# result [ 'ok' ] = True #NEWLINE# self . assertEqual ( result [ 'return' ] , self . client . remote_request ( 'some ident' , self . proxy . some_method , params ) ) #NEWLINE# self . assertEqual ( self . client . waiting_for_result , set ( ) ) #NEWLINE# self . assertEqual ( self . client . results , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# result [ 'ok' ] = False #NEWLINE# self . assertRaises ( TestException , self . client . remote_request , 'some ident' , self . proxy . some_method , params ) #NEWLINE# self . assertEqual ( self . client . waiting_for_result , set ( ) ) #NEWLINE# self . assertEqual ( self . client . results , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } )