#NEWLINE# def test_send( self ) : #NEWLINE# #INDENT# ctx = zmq . Context . instance ( ) #NEWLINE# A = ctx . socket ( zmq . PAIR ) #NEWLINE# B = ctx . socket ( zmq . PAIR ) #NEWLINE# A . bind ( 'inproc://test' ) #NEWLINE# B . connect ( 'inproc://test' ) #NEWLINE# msg = self . session . msg ( 'execute' , content = dict ( a = 10 ) ) #NEWLINE# self . session . send ( A , msg , ident = b'foo' , buffers = [ b'bar' ] ) #NEWLINE# ( ident , msg_list ) = self . session . feed_identities ( B . recv_multipart ( ) ) #NEWLINE# new_msg = self . session . deserialize ( msg_list ) #NEWLINE# self . assertEqual ( ident [ 0 ] , b'foo' ) #NEWLINE# self . assertEqual ( new_msg [ 'msg_id' ] , msg [ 'msg_id' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'msg_type' ] , msg [ 'msg_type' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'header' ] , msg [ 'header' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'content' ] , msg [ 'content' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'parent_header' ] , msg [ 'parent_header' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'metadata' ] , msg [ 'metadata' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'buffers' ] , [ b'bar' ] ) #NEWLINE# content = msg [ 'content' ] #NEWLINE# header = msg [ 'header' ] #NEWLINE# header [ 'msg_id' ] = self . session . msg_id #NEWLINE# parent = msg [ 'parent_header' ] #NEWLINE# metadata = msg [ 'metadata' ] #NEWLINE# msg_type = header [ 'msg_type' ] #NEWLINE# self . session . send ( A , None , content = content , parent = parent , header = header , metadata = metadata , ident = b'foo' , buffers = [ b'bar' ] ) #NEWLINE# ( ident , msg_list ) = self . session . feed_identities ( B . recv_multipart ( ) ) #NEWLINE# new_msg = self . session . deserialize ( msg_list ) #NEWLINE# self . assertEqual ( ident [ 0 ] , b'foo' ) #NEWLINE# self . assertEqual ( new_msg [ 'msg_id' ] , header [ 'msg_id' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'msg_type' ] , content [ 'msg_type' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'header' ] , msg [ 'header' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'content' ] , msg [ 'content' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'metadata' ] , msg [ 'metadata' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'parent_header' ] , msg [ 'parent_header' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'buffers' ] , [ b'bar' ] ) #NEWLINE# header [ 'msg_id' ] = self . session . msg_id #NEWLINE# self . session . send ( A , msg , ident = b'foo' , buffers = [ b'bar' ] ) #NEWLINE# ( ident , new_msg ) = self . session . recv ( B ) #NEWLINE# self . assertEqual ( ident [ 0 ] , b'foo' ) #NEWLINE# self . assertEqual ( new_msg [ 'msg_id' ] , header [ 'msg_id' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'msg_type' ] , msg [ 'msg_type' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'header' ] , msg [ 'header' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'content' ] , msg [ 'content' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'metadata' ] , msg [ 'metadata' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'parent_header' ] , msg [ 'parent_header' ] ) #NEWLINE# self . assertEqual ( new_msg [ 'buffers' ] , [ b'bar' ] ) #NEWLINE# A . close ( ) #NEWLINE# B . close ( ) #NEWLINE# ctx . term ( )