#NEWLINE# @ mock . patch ( ( '%s.manager.find_resource_managers' % BASE ) , return_value = [ mock . MagicMock ( ) , mock . MagicMock ( ) ] ) #NEWLINE# @ mock . patch ( ( '%s.manager.SeekAndDestroy' % BASE ) ) #NEWLINE# def test_cleanup_admin_with_api_versions( self , mock_seek_and_destroy , mock_find_resource_managers ) : #NEWLINE# #INDENT# ctx = { #NEWLINE# #INDENT# 'config' : { #NEWLINE# #INDENT# 'admin_cleanup' : [ 'a' , 'b' ] , #NEWLINE# 'api_versions' : { #NEWLINE# #INDENT# 'cinder' : { #NEWLINE# #INDENT# 'version' : '1' , #NEWLINE# 'service_type' : 'volume' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'admin' : mock . MagicMock ( ) , #NEWLINE# 'users' : mock . MagicMock ( ) , #NEWLINE# 'task' : mock . MagicMock ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# admin_cleanup = admin . AdminCleanup ( ctx ) #NEWLINE# admin_cleanup . setup ( ) #NEWLINE# admin_cleanup . cleanup ( ) #NEWLINE# mock_find_resource_managers . assert_called_once_with ( [ 'a' , 'b' ] , True ) #NEWLINE# mock_seek_and_destroy . assert_has_calls ( [ mock . call ( mock_find_resource_managers . return_value [ 0 ] , ctx [ 'admin' ] , ctx [ 'users' ] , ctx [ 'config' ] [ 'api_versions' ] ) , mock . call ( ) . exterminate ( ) , mock . call ( mock_find_resource_managers . return_value [ 1 ] , ctx [ 'admin' ] , ctx [ 'users' ] , ctx [ 'config' ] [ 'api_versions' ] ) , mock . call ( ) . exterminate ( ) ] )