Example #1
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 #2
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
Example #3
0
def test():
    words = get_words()
    rds = redis.Redis()
    print "Flush all redis data before insert new."
    rds.flushall()

    random_set(rds, words)
    print "random_set done"
    random_hset(rds, words)
    print "random_hset done"
    random_lpush(rds, words)
    print "random_lpush done"
    random_zadd(rds, words)

    lds = redis.Redis(port=6380)
    copy(rds, lds, 0)

    # for all keys
    keys = rds.scan(0, count=rds.dbsize())
    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" and not lds.hexists("hashName", key):
            print "List data not consistent"

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