Example #1
0
def test_ttl():
    keys, total = scan(rds, 1000)
    for key in keys:
        k_type = rds.type(key)
        rds.expire(key, (60 * 60 * 24))
        set_ttl(rds, lds, key, k_type)
        if rds.ttl(key):
            assert ledis_ttl(lds, key, k_type) > 0
Example #2
0
def test_ttl():
    keys, total = scan(rds, 1000)
    for key in keys:
        k_type = rds.type(key)
        rds.expire(key, (60 * 60 * 24))
        set_ttl(rds, lds, key, k_type)
        if rds.ttl(key):
            assert ledis_ttl(lds, key, k_type) > 0
Example #3
0
def test():
    words = get_words()
    print "Flush all redis data before insert new."
    rds.flushall()

    random_string(rds, words)
    print "random_string done"

    random_hash(rds, words)
    print "random_hash done"
    
    random_list(rds, words)
    print "random_list done"

    random_zset(rds, words)
    print "random_zset done"


    lds.lclear("listName")
    lds.hclear("hashName")
    lds.zclear("zsetName")
    copy(rds, lds, convert=True)

    # for all keys
    keys = scan(rds, 1000)
    for key in keys:
        if rds.type(key) == "string" and not lds.exists(key):
            print key
            print "String data not consistent"

    # for list
    l1 = rds.lrange("listName", 0, -1)
    l2 = lds.lrange("listName", 0, -1)
    assert l1 == l2
   
    #for hash
    for key in keys:
        if rds.type(key) == "hash":
            assert rds.hgetall(key) == lds.hgetall(key)
            assert sorted(rds.hkeys(key)) == sorted(lds.hkeys(key))
            assert sorted(rds.hvals(key)) == sorted(lds.hvals(key))

    # for zset
    z1 = rds.zrange("zsetName", 0, -1, withscores=True)
    z2 = lds.zrange("zsetName", 0, -1, withscores=True)
    assert z1 == z2
Example #4
0
def test():
    words = get_words()
    print "Flush all redis data before insert new."
    rds.flushall()

    random_string(rds, words)
    print "random_string done"

    random_hash(rds, words)
    print "random_hash done"

    random_list(rds, words)
    print "random_list done"

    random_zset(rds, words)
    print "random_zset done"

    random_set(rds, words)
    print "random_set done"

    copy(rds, lds, convert=True)

    # for all keys
    keys = scan(rds, 1000)
    for key in keys:
        if rds.type(key) == "string" and not lds.exists(key):
            print key
            print "String data not consistent"

    # for list
    l1 = rds.lrange("listName", 0, -1)
    l2 = lds.lrange("listName", 0, -1)
    assert l1 == l2

    #for hash
    for key in keys:
        if rds.type(key) == "hash":
            assert rds.hgetall(key) == lds.hgetall(key)
            assert sorted(rds.hkeys(key)) == sorted(lds.hkeys(key))
            assert sorted(rds.hvals(key)) == sorted(lds.hvals(key))

    # for zset
    z1 = rds.zrange("zsetName", 0, -1, withscores=True)
    z2 = lds.zrange("zsetName", 0, -1, withscores=True)
    assert z1 == z2