Пример #1
0
def test_spliturl():
    """Test spliturl."""
    root, path, args = spliturl("root://eosuser.cern.ch//eos/user/")
    assert root == "root://eosuser.cern.ch"
    assert path == "//eos/user/"

    root, path, args = spliturl("root://eosuser.cern.ch//")
    assert root == "root://eosuser.cern.ch"
    assert path == "//"

    root, path, arg = spliturl("root://eosuser.cern.ch//eos?xrd.wantprot=krb5")
    assert root == "root://eosuser.cern.ch"
    assert path == "//eos"
    assert arg == "xrd.wantprot=krb5"

    root, path, arg = spliturl("root://localhost//")
    assert root == "root://localhost"
    assert path == "//"
    assert arg == ""
Пример #2
0
def test_init(tmppath):
    """Test initialization."""
    fs = XRootDPyFS("root://127.0.0.1//tmp/")
    assert fs.xrd_client
    assert fs.base_path == "//tmp/"
    assert fs.root_url == "root://127.0.0.1"

    XRootDPyFS("root://*****:*****@eosuser.cern.ch//")
    XRootDPyFS("root://eosuser.cern.ch//")
    XRootDPyFS("root://eosuser.cern.ch//")
    pytest.raises(InvalidPathError, XRootDPyFS, "http://localhost")
    pytest.raises(InvalidPathError, XRootDPyFS,
                  "root://eosuser.cern.ch//lhc//")

    rooturl = mkurl(tmppath)
    fs = XRootDPyFS(rooturl)
    root_url, base_path, qargs = spliturl(rooturl)
    assert fs.xrd_client
    assert fs.base_path == base_path
    assert fs.root_url == root_url
    assert fs.queryargs is None

    qarg = "xrd.wantprot=krb5"
    fs = XRootDPyFS(rooturl + '?' + qarg)
    root_url, base_path, qargs = spliturl(rooturl + '?' + qarg)
    assert fs.base_path == base_path
    assert fs.root_url == root_url
    assert fs.queryargs == {'xrd.wantprot': 'krb5'}
    assert qargs == qarg

    qarg = "xrd.wantprot=krb5"
    fs = XRootDPyFS(rooturl + '?' + qarg, query={'xrd.k5ccname': '/tmp/krb'})

    assert fs.queryargs == {
        'xrd.wantprot': 'krb5',
        'xrd.k5ccname': '/tmp/krb',
    }

    pytest.raises(
        KeyError,
        XRootDPyFS,
        rooturl + '?' + qarg, query={'xrd.wantprot': 'krb5'}
    )
Пример #3
0
def test_init(tmppath):
    """Test initialization."""
    fs = XRootDPyFS("root://127.0.0.1//tmp/")
    assert fs.xrd_client
    assert fs.base_path == "//tmp/"
    assert fs.root_url == "root://127.0.0.1"

    XRootDPyFS("root://*****:*****@eosuser.cern.ch//")
    XRootDPyFS("root://eosuser.cern.ch//")
    XRootDPyFS("root://eosuser.cern.ch//")
    pytest.raises(InvalidPathError, XRootDPyFS, "http://localhost")
    pytest.raises(InvalidPathError, XRootDPyFS,
                  "root://eosuser.cern.ch//lhc//")

    rooturl = mkurl(tmppath)
    fs = XRootDPyFS(rooturl)
    root_url, base_path, qargs = spliturl(rooturl)
    assert fs.xrd_client
    assert fs.base_path == base_path
    assert fs.root_url == root_url
    assert fs.queryargs is None

    qarg = "xrd.wantprot=krb5"
    fs = XRootDPyFS(rooturl + '?' + qarg)
    root_url, base_path, qargs = spliturl(rooturl + '?' + qarg)
    assert fs.base_path == base_path
    assert fs.root_url == root_url
    assert fs.queryargs == {'xrd.wantprot': 'krb5'}
    assert qargs == qarg

    qarg = "xrd.wantprot=krb5"
    fs = XRootDPyFS(rooturl + '?' + qarg, query={'xrd.k5ccname': '/tmp/krb'})

    assert fs.queryargs == {
        'xrd.wantprot': 'krb5',
        'xrd.k5ccname': '/tmp/krb',
    }

    pytest.raises(
        KeyError,
        XRootDPyFS,
        rooturl + '?' + qarg, query={'xrd.wantprot': 'krb5'}
    )
Пример #4
0
def test_spliturl():
    """Test spliturl."""
    root, path, args = spliturl("root://eosuser.cern.ch//eos/user/")
    assert root == "root://eosuser.cern.ch"
    assert path == "//eos/user/"

    root, path, args = spliturl("root://eosuser.cern.ch//")
    assert root == "root://eosuser.cern.ch"
    assert path == "//"

    root, path, arg = spliturl("root://eosuser.cern.ch//eos?xrd.wantprot=krb5")
    assert root == "root://eosuser.cern.ch"
    assert path == "//eos"
    assert arg == "xrd.wantprot=krb5"

    root, path, arg = spliturl("root://localhost//")
    assert root == "root://localhost"
    assert path == "//"
    assert arg == ""