#NEWLINE# @ mock . patch ( 'rally.osclients.Clients' ) #NEWLINE# @ mock . patch ( 'rally.plugins.openstack.wrappers.network.wrap' ) #NEWLINE# def test_setup( self , mock_network_wrap , mock_clients ) : #NEWLINE# #INDENT# networks = [ mock . Mock ( ) , mock . Mock ( ) , mock . Mock ( ) ] #NEWLINE# net_wrappers = { #NEWLINE# #INDENT# 'tenant1' : mock . Mock ( ** { #NEWLINE# #INDENT# 'list_networks.return_value' : networks [ 0 : 2 ] , #NEWLINE# #UNINDENT# } ) , #NEWLINE# 'tenant2' : mock . Mock ( ** { #NEWLINE# #INDENT# 'list_networks.return_value' : networks [ 2 : ] , #NEWLINE# #UNINDENT# } ) , #NEWLINE# #UNINDENT# } #NEWLINE# mock_network_wrap . side_effect = [ net_wrappers [ 'tenant1' ] , net_wrappers [ 'tenant2' ] ] #NEWLINE# context = existing_network . ExistingNetwork ( self . context ) #NEWLINE# context . setup ( ) #NEWLINE# mock_clients . assert_has_calls ( [ mock . call ( u [ 'credential' ] ) for u in self . context [ 'users' ] ] ) #NEWLINE# mock_network_wrap . assert_has_calls ( [ mock . call ( mock_clients . return_value , context , config = self . config ) , mock . call ( mock_clients . return_value , context , config = self . config ) ] ) #NEWLINE# for net_wrapper in net_wrappers . values ( ) : #NEWLINE# #INDENT# net_wrapper . list_networks . assert_called_once_with ( ) #NEWLINE# #UNINDENT# self . assertDictEqual ( self . context [ 'tenants' ] , { #NEWLINE# #INDENT# 'tenant1' : { #NEWLINE# #INDENT# 'networks' : networks [ 0 : 2 ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'tenant2' : { #NEWLINE# #INDENT# 'networks' : networks [ 2 : ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } )