示例#1
0
def test_session_lookups():
    uids = range(10000, 10010)
    groups = ['grp1', 'grp2']
    for uid in uids:
        sid = sessionslib.create(uid, groups)
        assert sessionslib.sid2uidgroups(sid) == (uid, groups)
        sessionslib.destroy(sid)
        assert sessionslib.get(sid) == {}
示例#2
0
def test_session_lookups():
    uids = xrange(10000, 10010)
    groups = ['grp1', 'grp2']
    for uid in uids:
        sid = sessionslib.create(uid, groups)
        assert sessionslib.sid2uidgroups(sid) == (uid, groups)
        sessionslib.destroy(sid)
        assert sessionslib.get(sid) == {}
示例#3
0
def test_sessions():
    uid, groups, k, v = 98765, ['admin', 'member'], 'foo', 'bar'
    sid = sessionslib.create(uid, groups)
    assert len(sid) > 43
    sid_new = sessionslib.create(uid, groups)
    assert sid == sid_new
    sessionslib.update(sid, {k: v})
    d = sessionslib.get(sid)
    assert d[k] == v
    sessionslib.remove_from_session(sid, k)
    d = sessionslib.get(sid)
    assert k not in d
    sessionslib.destroy(sid)
    assert sessionslib.get(sid) == {}
示例#4
0
def test_sessions():
    uid, groups, k, v = 98765, ['admin', 'member'], 'foo', 'bar'
    sid = sessionslib.create(uid, groups)
    assert len(sid) > 43
    sid_new = sessionslib.create(uid, groups)
    assert sid == sid_new
    sessionslib.add_to_session(sid, {k: v})
    d = sessionslib.get(sid)
    assert d[k] == v
    sessionslib.remove_from_session(sid, k)
    d = sessionslib.get(sid)
    assert k not in d
    sessionslib.destroy(sid)
    assert sessionslib.get(sid) == {}
示例#5
0
def test_sessions():
    uid, groups, k, v = 987651, ['admin', 'member'], 'foo', 'bar'
    sid = sessionslib.create(uid, groups, extras=dict(email='*****@*****.**'))
    assert len(sid) == 43
    sid_new = sessionslib.create(uid, groups)
    assert sid == sid_new
    sessionslib.update(sid, {k: v})
    d = sessionslib.get(sid)
    assert d[k] == v
    assert d['email'] == '*****@*****.**'
    sessionslib.remove_from_session(sid, k)
    d = sessionslib.get(sid)
    assert k not in d
    sessionslib.destroy(sid)
    assert sessionslib.get(sid) == {}
示例#6
0
def test_delete_session():

    sid = sessions.create()
    data = sessions.get(sid)
    data['prefs'] = {'last_seen': '10/05/2016'}
    assert sessions.update(sid, data)

    data = sessions.get(sid)
    assert data['prefs']['last_seen'] == '10/05/2016'

    assert sessions.destroy(sid)

    data = sessions.get(sid)
    assert data == {}