Exemple #1
0
def test_sored_list():
    redis.flush_db()
    l = SortedList(scope_name='recents')
    l.append('a', 1)
    l.append({'hi': 'me'}, 2)
    assert (l[0:-1] == ['a', {'hi': 'me'}])
    assert (l[-1:0] == [{'hi': 'me'}, 'a'])
Exemple #2
0
def test_kv_store_update():
    redis.flush_db()
    kv = KeyValueStore(scope_name='user-1000')
    kv['meta'] = {'user-name': 'tianlin.shi', 'num-files': 100}
    assert (kv['meta']['user-name'] == 'tianlin.shi')
    assert (kv['meta']['num-files'] == 100)
    kv.update({'meta': None, 'gender': 'male'})
    assert (kv['meta'] is None)
    assert (kv['gender'] == 'male')
Exemple #3
0
def test_scoped_kv_store():
    redis.flush_db()
    kv = KeyValueStore(scope_name='user-1000')
    kv['meta'] = {'user-name': 'tim.shi', 'num-files': 100}
    kv = KeyValueStore(scope_name='user-101')
    assert ('meta' not in kv)
    kv = KeyValueStore(scope_name='user-1000')
    assert (kv['meta']['user-name'] == 'tim.shi')
    assert (kv['meta']['num-files'] == 100)
Exemple #4
0
def test_kv_store():
    redis.flush_db()
    kv = KeyValueStore(scope_name=None)
    kv['meta'] = {'site-name': 'sharead', 'num-users': 1000}
    assert (kv['meta']['site-name'] == 'sharead')
    assert (kv['meta']['num-users'] == 1000)
Exemple #5
0
def test_kv_delete():
    redis.flush_db()
    kv = KeyValueStore(scope_name='user-1000')
    kv['name'] = 'tim'
    kv.remove('name')
    assert (kv['name'] is None)
Exemple #6
0
def test_kv_store_mget():
    redis.flush_db()
    kv = KeyValueStore(scope_name='user-1000')
    kv['name'] = 'tim'
    kv['gender'] = 'male'
    assert (kv.mget(['name', 'gender']) == {'name': 'tim', 'gender': 'male'})