当前位置: 首页>>代码示例>>Python>>正文


Python XROOTStorage.putDirectory方法代码示例

本文整理汇总了Python中DIRAC.Resources.Storage.XROOTStorage.XROOTStorage.putDirectory方法的典型用法代码示例。如果您正苦于以下问题:Python XROOTStorage.putDirectory方法的具体用法?Python XROOTStorage.putDirectory怎么用?Python XROOTStorage.putDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.Resources.Storage.XROOTStorage.XROOTStorage的用法示例。


在下文中一共展示了XROOTStorage.putDirectory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_putDirectory

# 需要导入模块: from DIRAC.Resources.Storage.XROOTStorage import XROOTStorage [as 别名]
# 或者: from DIRAC.Resources.Storage.XROOTStorage.XROOTStorage import putDirectory [as 别名]
  def test_putDirectory(self):
    ''' tests the output of putDirectory
    '''
    global mocked_xrootclient

    # I again try to have 2 subdirs, and 1 file per subdir and 1 file a the root

    resource = XROOTStorage('storageName', self.parameterDict)

    statusCopyMock = xrootStatusMock()
    statusCopyMock.makeOk()

    mocked_xrootclient.copy.return_value = statusCopyMock, None

    statusMkDirMock = xrootStatusMock()
    statusMkDirMock.makeOk()

    mocked_xrootclient.mkdir.return_value = statusMkDirMock, None

    statusRmMock = xrootStatusMock()
    statusRmMock.makeOk()

    mocked_xrootclient.rm.return_value = statusRmMock, None

    statusStatMock = xrootStatusMock()
    statusStatMock.makeOk()
    statInfoMock = xrootStatInfoMock()
    statInfoMock.makeFile()
    statInfoMock.size = 1

    updateStatMockReferences(statusStatMock, statInfoMock)

    # This test should upload the 3 files
    copymock = mock.Mock()
    copymock.run.return_value = statusCopyMock, None
    mocked_xrootd.client.CopyProcess = mock.Mock(return_value=copymock)
    res = resource.putDirectory({"remoteA": "localA"})
    self.assertEqual(True, res['OK'])
    self.assertEqual({"remoteA": {"Files": 3, "Size": 3}}, res['Value']['Successful'])
    self.assertEqual({}, res['Value']['Failed'])

    # The copy command is just in error
    statusCopyMock.makeError()
    copymock.run.return_value = statusCopyMock, None
    mocked_xrootd.client.CopyProcess = mock.Mock(return_value=copymock)
    with mock.patch('os.path.isdir',
                    new=MagicMock(side_effect=[True,
                                               True,
                                               True,
                                               False,
                                               True,
                                               True,
                                               False,
                                               False])), mock.patch('os.listdir',
                                                                    new=MagicMock(side_effect=[("dir1",
                                                                                                "dir2",
                                                                                                "file1"),
                                                                                  ("file2", ), ("file3", )])):
      res = resource.putDirectory({"remoteA": "localA"})
    self.assertEqual(True, res['OK'])
    self.assertEqual({}, res['Value']['Successful'])
    self.assertEqual({"remoteA": {"Files": 0, "Size": 0}}, res['Value']['Failed'])

    # The copy command is fatal
    statusCopyMock.makeFatal()
    copymock.run.return_value = statusCopyMock, None
    mocked_xrootd.client.CopyProcess = mock.Mock(return_value=copymock)
    with mock.patch('os.path.isdir',
                    new=MagicMock(side_effect=[True,
                                               True,
                                               True,
                                               False,
                                               True,
                                               True,
                                               False,
                                               False])), mock.patch('os.listdir',
                                                                    new=MagicMock(side_effect=[("dir1",
                                                                                                "dir2",
                                                                                                "file1"),
                                                                                  ("file2", ), ("file3", )])):
      res = resource.putDirectory({"remoteA": "localA"})
    self.assertEqual(True, res['OK'])
    self.assertEqual({}, res['Value']['Successful'])
    self.assertEqual({"remoteA": {"Files": 0, "Size": 0}}, res['Value']['Failed'])
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:86,代码来源:Test_XROOTStorage.py


注:本文中的DIRAC.Resources.Storage.XROOTStorage.XROOTStorage.putDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。