def test_list():
    lightcloud.list_varnish('hello')

    lightcloud.list_add('hello', ['1', '2', '3'])
    lightcloud.list_add('hello', ['4'])
    assert lightcloud.list_get('hello') == ['4', '1', '2', '3']

    lightcloud.list_remove('hello', ['3'])
    assert lightcloud.list_get('hello') == ['4', '1', '2']
def test_list():
    lightcloud.list_varnish('hello')

    lightcloud.list_add('hello', ['1', '2', '3'])
    lightcloud.list_add('hello', ['4'])
    assert lightcloud.list_get('hello') == ['4', '1', '2', '3']

    lightcloud.list_remove('hello', ['3'])
    assert lightcloud.list_get('hello') == ['4', '1', '2']
def test_limit_add():
    lightcloud.list_varnish('hello')

    for i in range(0, 250):
        lightcloud.list_add('hello', [i])
    assert len(lightcloud.list_get('hello')) == 200

    lightcloud.list_varnish('hello')
    for i in range(0, 100):
        lightcloud.list_add('hello', [i], limit=50)
    assert len(lightcloud.list_get('hello')) == 50

    cur = lightcloud.list_get('hello')
    i = 100
    for elm in cur:
        i -= 1
        assert elm == str(i)
def test_limit_add():
    lightcloud.list_varnish('hello')

    for i in range(0, 250):
        lightcloud.list_add('hello', [i])
    assert len(lightcloud.list_get('hello')) == 200

    lightcloud.list_varnish('hello')
    for i in range(0, 100):
        lightcloud.list_add('hello', [i], limit=50)
    assert len(lightcloud.list_get('hello')) == 50

    cur = lightcloud.list_get('hello')
    i = 100
    for elm in cur:
        i -= 1
        assert elm == str(i)
Exemple #5
0
def get_offends(key, system='default'):
    """Returns a list of offends that are registreted for `key`.

    The return structure is [(date1, extra_data1), ..., (dateN, extra_dataN)]
    """
    result = []
    ll = lightcloud.list_get('offends_%s' % key, system=system)
    for item in ll:
        sp = item.split('///')
        result.append((get_datetime(float(sp[0])), sp[1]))
    return result
Exemple #6
0
def get_offends(key, system='default'):
    """Returns a list of offends that are registreted for `key`.

    The return structure is [(date1, extra_data1), ..., (dateN, extra_dataN)]
    """
    result = []
    ll = lightcloud.list_get('offends_%s' % key, system=system)
    for item in ll:
        sp = item.split('///')
        result.append( (get_datetime(float(sp[0])), sp[1]) )
    return result
Exemple #7
0
 def get(self, key):
     """
     Retrieves the value of a key from the lightcloud store
     
     @param key: the key to retrieve
     
     @return: list of the value(s) if exist,  empty list otherwise
     """
     #try to retrieve a list of the values, if the key doesnt exist in the list keys then try to get it from the normal keys
     result = lightcloud.list_get(key)
     if isinstance(result, list):
         return result
     result = lightcloud.get(key)
     if result:
         return [result]
     return list()
Exemple #8
0
 def get(self, key):
     """
     Retrieves the value of a key from the lightcloud store
     
     @param key: the key to retrieve
     
     @return: list of the value(s) if exist,  empty list otherwise
     """
     #try to retrieve a list of the values, if the key doesnt exist in the list keys then try to get it from the normal keys
     result = lightcloud.list_get(key)
     if isinstance(result, list):
         return result
     result = lightcloud.get(key)
     if result:
         return [result]
     return list()