#NEWLINE# def test_provided_connections( self ) : #NEWLINE# #INDENT# cm = self . runtime_environment . configuration_manager #NEWLINE# cm . set ( 'amqp.rpc_clients.test_client' , dict ( connection = 'test_connection' , type = reflect . fullyQualifiedName ( StubRPCClient ) , consumer = dict ( queue = dict ( queue = 'my_queue' ) ) ) ) #NEWLINE# provider = rpc . RPCClientProvider ( ) #NEWLINE# provider . configure ( self . runtime_environment ) #NEWLINE# client_dependency = dependencies . ResourceDependency ( provider = 'amqp.rpc_client.test_client' ) #NEWLINE# self . runtime_environment . resource_manager . resolve ( client_dependency ) #NEWLINE# mocked_connection = mock . Mock ( ) #NEWLINE# mocked_connection . channel . return_value . basic_consume . return_value = ( defer . DeferredQueue ( ) , mock . Mock ( ) ) #NEWLINE# with patch . object ( self . runtime_environment . resource_manager , 'resolve' ) as mocked_resolve : #NEWLINE# #INDENT# def resolve( resource_dependency ) : #NEWLINE# #INDENT# self . assertEquals ( resource_dependency . provider , 'amqp.connection.test_connection' ) #NEWLINE# resource_dependency . on_resource_ready ( mocked_connection ) #NEWLINE# #UNINDENT# mocked_resolve . side_effect = resolve #NEWLINE# self . runtime_environment . dependency_manager . resolve_initial_states ( ) #NEWLINE# provider . startService ( ) #NEWLINE# #UNINDENT# client = client_dependency . get_resource ( ) #NEWLINE# self . assertIsInstance ( client , StubRPCClient ) #NEWLINE# self . assertEquals ( provider . response_queue_declare [ 'queue' ] , 'my_queue' ) #NEWLINE# another_client_dependency = dependencies . ResourceDependency ( provider = 'amqp.rpc_client.test_client' ) #NEWLINE# self . runtime_environment . resource_manager . resolve ( another_client_dependency ) #NEWLINE# self . assertIdentical ( another_client_dependency . get_resource ( ) , client_dependency . get_resource ( ) )