示例#1
0
def test_unicode_paths(tmppath):
    """Test creation of unicode paths."""
    fs = XRootDPyFS(mkurl(tmppath))
    d = u'\xe6\xf8\xe5'
    assert not fs.exists(d)
    assert fs.makedir(d)
    assert fs.exists(d)
    d = '\xc3\xb8\xc3\xa5\xc3\xa6'
    assert not fs.exists(d)
    assert fs.makedir(d)
    assert fs.exists(d)
示例#2
0
def test_unicode_paths(tmppath):
    """Test creation of unicode paths."""
    fs = XRootDPyFS(mkurl(tmppath))
    d = u'\xe6\xf8\xe5'
    assert not fs.exists(d)
    assert fs.makedir(d)
    assert fs.exists(d)
    d = '\xc3\xb8\xc3\xa5\xc3\xa6'
    assert not fs.exists(d)
    assert fs.makedir(d)
    assert fs.exists(d)
示例#3
0
    def _get_fs(self, create_dir=True, query=None):
        """Get PyFilesystem instance and path."""
        # Fall-back to PyFS in case of non-xrootd URL
        if not self.fileurl.startswith(('root://', 'roots://')):
            return super(XRootDFileStorage,
                         self)._get_fs(create_dir=create_dir)
        filedir = dirname(self.fileurl)
        filename = basename(self.fileurl)

        if query is None:
            fs = XRootDPyFS(filedir)
        else:
            fs = XRootDPyFS(filedir, query)

        if create_dir:
            fs.makedir('', recursive=True, allow_recreate=True)

        return (fs, filename)
示例#4
0
def test_remove_dir(tmppath):
    """Test removedir."""
    fs = XRootDPyFS(mkurl(tmppath))

    # Remove non-empty directory
    pytest.raises(DirectoryNotEmptyError, fs.removedir, "data/bfolder/")

    # Use of recursive parameter
    pytest.raises(UnsupportedError,
                  fs.removedir,
                  "data/bfolder/",
                  recursive=True)

    # Remove file
    pytest.raises(ResourceInvalidError, fs.removedir, "data/testa.txt")

    # Remove empty directory
    fs.makedir("data/tmp")
    assert fs.removedir("data/tmp") and not fs.exists("data/tmp")

    # Remove non-empty directory
    assert fs.removedir("data/bfolder/", force=True)
    assert fs.removedir("data/", force=True)
示例#5
0
def test_remove_dir(tmppath):
    """Test removedir."""
    fs = XRootDPyFS(mkurl(tmppath))

    # Remove non-empty directory
    pytest.raises(
        DirectoryNotEmptyError, fs.removedir, "data/bfolder/")

    # Use of recursive parameter
    pytest.raises(
        UnsupportedError, fs.removedir, "data/bfolder/", recursive=True)

    # Remove file
    pytest.raises(
        ResourceInvalidError, fs.removedir, "data/testa.txt")

    # Remove empty directory
    fs.makedir("data/tmp")
    assert fs.removedir("data/tmp") and not fs.exists("data/tmp")

    # Remove non-empty directory
    assert fs.removedir("data/bfolder/", force=True)
    assert fs.removedir("data/", force=True)