#NEWLINE# def test_binding_and_connecting( self ) : #NEWLINE# #INDENT# queues = dict ( connect_and_bind = dict ( type = 'PUSH' , binds = [ 'inproc://socketname' ] , connects = [ 'tcp://0.0.0.0:1234' ] ) , multiple_connects = dict ( type = 'PUSH' , connects = [ 'tcp://0.0.0.0:1234' , 'tcp://0.0.0.0:1235' ] ) , multiple_binds = dict ( type = 'PUSH' , binds = [ 'tcp://0.0.0.0:1234' , 'tcp://0.0.0.0:1235' ] ) , no_connects_nor_binds = dict ( type = 'PUSH' ) ) #NEWLINE# self . runtime_environment . configuration_manager . set ( 'zmq.queues' , queues ) #NEWLINE# socket_provider = providers . ZMQSocketProvider ( ) #NEWLINE# context = self . mocker . mock ( ) #NEWLINE# socket_provider . context_factory = ( lambda : context ) #NEWLINE# sockets = dict ( ( ( queue_name , self . mocker . mock ( ) ) for queue_name in queues ) ) #NEWLINE# for queue_name in queues : #NEWLINE# #INDENT# mocked_socket = sockets [ queue_name ] #NEWLINE# context . socket ( zmq . PUSH ) #NEWLINE# self . mocker . result ( mocked_socket ) #NEWLINE# for bind_spec in queues [ queue_name ] . get ( 'binds' , [ ] ) : #NEWLINE# #INDENT# mocked_socket . bind ( bind_spec ) #NEWLINE# #UNINDENT# for connect_spec in queues [ queue_name ] . get ( 'connects' , [ ] ) : #NEWLINE# #INDENT# mocked_socket . connect ( connect_spec ) #NEWLINE# #UNINDENT# #UNINDENT# self . mocker . replay ( ) #NEWLINE# socket_provider . configure ( self . runtime_environment ) #NEWLINE# for queue_name in queues : #NEWLINE# #INDENT# resource_dependency = dependencies . ResourceDependency ( provider = ( 'zmq.socket.%s' % queue_name ) ) #NEWLINE# socket_provider . add_consumer ( resource_dependency ) #NEWLINE# #UNINDENT# socket_provider . start_providing ( ) #NEWLINE# self . mocker . verify ( )