#NEWLINE# @ mock . patch ( 'rally.osclients.Clients' ) #NEWLINE# @ mock . patch ( ( MANILA_UTILS_PATH + '_list_share_networks' ) ) #NEWLINE# def test_setup_use_existing_share_networks( self , mock_manila_scenario__list_share_networks , mock_clients ) : #NEWLINE# #INDENT# existing_sns = self . existing_sns #NEWLINE# inst = manila_share_networks . ManilaShareNetworks ( self . ctxt_use_existing ) #NEWLINE# mock_manila_scenario__list_share_networks . return_value = self . existing_sns #NEWLINE# expected_ctxt = copy . deepcopy ( self . ctxt_use_existing ) #NEWLINE# expected_ctxt . update ( { #NEWLINE# #INDENT# 'delete_share_networks' : False , #NEWLINE# 'tenants' : { #NEWLINE# #INDENT# 'tenant_1_id' : { #NEWLINE# #INDENT# 'id' : 'tenant_1_id' , #NEWLINE# 'name' : 'tenant_1_name' , #NEWLINE# consts . SHARE_NETWORKS_CONTEXT_NAME : { #NEWLINE# #INDENT# 'share_networks' : [ sn for sn in existing_sns [ 0 : 2 ] ] , #NEWLINE# 'sn_iterator' : mock . ANY , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'tenant_2_id' : { #NEWLINE# #INDENT# 'id' : 'tenant_2_id' , #NEWLINE# 'name' : 'tenant_2_name' , #NEWLINE# consts . SHARE_NETWORKS_CONTEXT_NAME : { #NEWLINE# #INDENT# 'share_networks' : [ sn for sn in existing_sns [ 2 : 5 ] ] , #NEWLINE# 'sn_iterator' : mock . ANY , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# inst . setup ( ) #NEWLINE# self . assertEqual ( expected_ctxt [ 'task' ] , inst . context . get ( 'task' ) ) #NEWLINE# self . assertEqual ( expected_ctxt [ 'config' ] , inst . context . get ( 'config' ) ) #NEWLINE# self . assertEqual ( expected_ctxt [ 'users' ] , inst . context . get ( 'users' ) ) #NEWLINE# self . assertEqual ( False , inst . context . get ( consts . SHARE_NETWORKS_CONTEXT_NAME , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . get ( 'delete_share_networks' ) ) #NEWLINE# self . assertEqual ( expected_ctxt [ 'tenants' ] , inst . context . get ( 'tenants' ) ) #NEWLINE# for ( i , sns ) in ( ( 1 , existing_sns [ 0 : 2 ] ) , ( 2 , existing_sns [ 2 : 5 ] ) ) : #NEWLINE# #INDENT# self . assertIsInstance ( self . context [ 'tenants' ] [ ( 'tenant_%s_id' % i ) ] [ consts . SHARE_NETWORKS_CONTEXT_NAME ] [ 'sn_iterator' ] , utils . RAMInt ) #NEWLINE# for j in range ( 12 ) : #NEWLINE# #INDENT# self . assertEqual ( j , next ( inst . context [ 'tenants' ] [ ( 'tenant_%s_id' % i ) ] [ consts . SHARE_NETWORKS_CONTEXT_NAME ] [ 'sn_iterator' ] ) )