def test_remove_dir_mock2(tmppath): """Test removedir.""" fs = XRootDFS(mkurl(tmppath)) status = XRootDStatus( { "status": 3, "code": 101, "ok": False, "errno": 0, "error": True, "message": "[FATAL] Invalid address", "fatal": True, "shellcode": 51, } ) def fail(f, fail_on): @wraps(f) def inner(path, **kwargs): if path == fail_on: return (status, None) return f(path, **kwargs) return inner fs.xrd_client.rmdir = fail(fs.xrd_client.rmdir, fs._p("data/bfolder/")) pytest.raises(ResourceError, fs.removedir, "data/", force=True)
def test_remove_dir_mock2(tmppath): """Test removedir.""" fs = XRootDFS(mkurl(tmppath)) status = XRootDStatus({ "status": 3, "code": 101, "ok": False, "errno": 0, "error": True, "message": '[FATAL] Invalid address', "fatal": True, "shellcode": 51 }) def fail(f, fail_on): @wraps(f) def inner(path, **kwargs): if path == fail_on: return (status, None) return f(path, **kwargs) return inner fs.xrd_client.rmdir = fail(fs.xrd_client.rmdir, fs._p("data/bfolder/")) pytest.raises(ResourceError, fs.removedir, "data/", force=True)
def test_p(): """Test path combine.""" fs = XRootDFS("root://eosuser.cern.ch//eos/user/") assert fs._p("./") == "//eos/user" assert fs._p("l") == "//eos/user/l" assert fs._p("/eos") == "//eos" assert fs._p("../") == "//eos" assert fs._p("../project/test") == "//eos/project/test" assert fs._p("../project/../test") == "//eos/test" pytest.raises(BackReferenceError, fs._p, "../../../test")