Exemplo n.º 1
0
def test_status_no_sessionId(client, case):
    """Call getStatus() while logged out.

    IDS 1.5.0 and newer allow the sessionId to be omitted from the
    getStatus() call.
    """
    if client.ids.apiversion < '1.5.0':
        pytest.skip("IDS %s is too old, need 1.5.0 or newer" 
                    % client.ids.apiversion)
    selection = DataSelection([getDataset(client, case)])
    with tmpSessionId(client, None):
        status = client.ids.getStatus(selection)
    print("Status of dataset %s: %s" % (case['dsname'], status))
    assert status in {"ONLINE", "RESTORING", "ARCHIVED"}
Exemplo n.º 2
0
def test_status_no_sessionId(client, case):
    """Call getStatus() while logged out.

    IDS 1.5.0 and newer allow the sessionId to be omitted from the
    getStatus() call.
    """
    if client.ids.apiversion < '1.5.0':
        pytest.skip("IDS %s is too old, need 1.5.0 or newer" 
                    % client.ids.apiversion)
    query = Query(client, "Dataset", conditions={
        "name": "= '%s'" % case['dsname'],
        "investigation.name": "= '%s'" % case['invname'],
    })
    selection = DataSelection(client.assertedSearch(query))
    with tmpSessionId(client, None):
        status = client.ids.getStatus(selection)
    print("Status of dataset %s: %s" % (case['dsname'], status))
    assert status in {"ONLINE", "RESTORING", "ARCHIVED"}
Exemplo n.º 3
0
def test_login(user):
    """Login to the ICAT server.
    """

    client, conf = getConfig(confSection=user)
    sessionId = client.login(conf.auth, conf.credentials)
    assert sessionId
    assert sessionId == client.sessionId
    username = client.getUserName()
    assert username == "%s/%s" % (conf.auth, user)
    print("\nLogged in as %s to %s." % (user, conf.url))
    client.logout()
    assert client.sessionId is None

    # Verify that the logout was effective, e.g. that the sessionId is
    # invalidated.
    with tmpSessionId(client, sessionId):
        with pytest.raises(icat.exception.ICATSessionError):
            username = client.getUserName()
Exemplo n.º 4
0
def test_login(user):
    """Login to the ICAT server.
    """

    conf = getConfig(confSection=user)
    client = icat.Client(conf.url, **conf.client_kwargs)
    sessionId = client.login(conf.auth, conf.credentials)
    assert sessionId
    assert sessionId == client.sessionId
    username = client.getUserName()
    assert username == user
    print("\nLogged in as %s to %s." % (user, conf.url))
    client.logout()
    assert client.sessionId is None

    # Verify that the logout was effective, e.g. that the sessionId is
    # invalidated.
    with tmpSessionId(client, sessionId):
        with pytest.raises(icat.exception.ICATSessionError):
            username = client.getUserName()
Exemplo n.º 5
0
def test_status_no_sessionId(client, case):
    """Call getStatus() while logged out.

    IDS 1.5.0 and newer allow the sessionId to be omitted from the
    getStatus() call.
    """
    if client.ids.apiversion < '1.5.0':
        pytest.skip("IDS %s is too old, need 1.5.0 or newer" %
                    client.ids.apiversion)
    query = Query(client,
                  "Dataset",
                  conditions={
                      "name": "= '%s'" % case['dsname'],
                      "investigation.name": "= '%s'" % case['invname'],
                  })
    selection = DataSelection(client.assertedSearch(query))
    with tmpSessionId(client, None):
        status = client.ids.getStatus(selection)
    print("Status of dataset %s: %s" % (case['dsname'], status))
    assert status in {"ONLINE", "RESTORING", "ARCHIVED"}
Exemplo n.º 6
0
def test_logout_no_session_error(client):
    """Issue #43: logout() should silently ignore ICATSessionError.
    """
    with tmpSessionId(client, "-=- Invalid -=-"):
        client.logout()
Exemplo n.º 7
0
def provokeICATSessionError(client):
    print("Provoke an ICATSessionError ...")
    invalidid = '-=- INVALID ID -=-'
    with tmpSessionId(client, invalidid):
        client.search("Facility")