def common_mocks(f):
 def _FakeRetrying(wait_func=None, original_retrying=driver.utils.retrying.Retrying, *args, **kwargs):
  return original_retrying(wait_func=(lambda *a, **k: 0), *args, **kwargs)
 def _common_inner_inner1(inst, *args, **kwargs):
  @mock.patch('retrying.Retrying', _FakeRetrying)
  @mock.patch.object(driver.RBDDriver, '_get_usage_info')
  @mock.patch('cinder.volume.drivers.rbd.RBDVolumeProxy')
  @mock.patch('cinder.volume.drivers.rbd.RADOSClient')
  @mock.patch('cinder.backup.drivers.ceph.rbd')
  @mock.patch('cinder.backup.drivers.ceph.rados')
  def _common_inner_inner2(mock_rados, mock_rbd, mock_client, mock_proxy, mock_usage_info):
   inst.mock_rbd = mock_rbd
   inst.mock_rados = mock_rados
   inst.mock_client = mock_client
   inst.mock_proxy = mock_proxy
   inst.mock_rbd.RBD.Error = Exception
   inst.mock_rados.Error = Exception
   inst.mock_rbd.ImageBusy = MockImageBusyException
   inst.mock_rbd.ImageNotFound = MockImageNotFoundException
   inst.mock_rbd.ImageExists = MockImageExistsException
   inst.mock_rbd.InvalidArgument = MockImageNotFoundException
   inst.driver.rbd = inst.mock_rbd
   inst.driver.rados = inst.mock_rados
   return f(inst, *args, **kwargs)
  return _common_inner_inner2()
 return _common_inner_inner1

def common_mocks ( f ) : def _FakeRetrying ( wait_func = None , original_retrying = driver . utils . retrying . Retrying , * args , ** kwargs ) : return original_retrying ( wait_func = ( lambda * a , ** k : 0 ) , * args , ** kwargs ) def _common_inner_inner1 ( inst , * args , ** kwargs ) : @ mock . patch ( 'retrying.Retrying' , _FakeRetrying ) @ mock . patch . object ( driver . RBDDriver , '_get_usage_info' ) @ mock . patch ( 'cinder.volume.drivers.rbd.RBDVolumeProxy' ) @ mock . patch ( 'cinder.volume.drivers.rbd.RADOSClient' ) @ mock . patch ( 'cinder.backup.drivers.ceph.rbd' ) @ mock . patch ( 'cinder.backup.drivers.ceph.rados' ) def _common_inner_inner2 ( mock_rados , mock_rbd , mock_client , mock_proxy , mock_usage_info ) : inst . mock_rbd = mock_rbd inst . mock_rados = mock_rados inst . mock_client = mock_client inst . mock_proxy = mock_proxy inst . mock_rbd . RBD . Error = Exception inst . mock_rados . Error = Exception inst . mock_rbd . ImageBusy = MockImageBusyException inst . mock_rbd . ImageNotFound = MockImageNotFoundException inst . mock_rbd . ImageExists = MockImageExistsException inst . mock_rbd . InvalidArgument = MockImageNotFoundException inst . driver . rbd = inst . mock_rbd inst . driver . rados = inst . mock_rados return f ( inst , * args , ** kwargs ) return _common_inner_inner2 ( ) return _common_inner_inner1
decorator to set mocks common to all tests .