def test_exists(self): key = 'dqtest-{}'.format(uuid4()) assert not Redis.exists(key) Redis.set(key, '1') assert Redis.exists(key) assert Redis.delete(key) assert not Redis.exists(key)
def test_list(self): key = 'dqtest-{}'.format(uuid4()) assert not Redis.lpeek(key, 1) assert not Redis.lpop(key, 1) assert Redis.rpush(key, 1, 2) assert Redis.rpush(key, '3', [1, 2]) assert Redis.lpeek(key, 1) == ['1'] assert Redis.lpeek(key, 2) == ['1', '2'] assert Redis.lpop(key, 2) == ['1', '2'] assert Redis.lpop(key, 3) == ['3', '[1, 2]'] assert not Redis.exists(key)
def test_hash(self): key = 'dqtest-{}'.format(uuid4()) assert not Redis.hgetall(key) assert not Redis.hget(key, '1') assert Redis.hset(key, '1', '1') assert Redis.hget(key, '1') == '1' assert Redis.hset(key, '2', '3') assert Redis.hget(key, '2') == '3' assert Redis.hset(key, '3', {'cornell': '#1'}) assert Redis.hget(key, '3') == '{"cornell": "#1"}' assert Redis.hgetall(key) == { '1': '1', '2': '3', '3': '{"cornell": "#1"}' } assert Redis.hdelete(key, '1') assert Redis.hgetall(key) == {'2': '3', '3': '{"cornell": "#1"}'} assert Redis.delete(key) assert not Redis.exists(key)
def test_expire(self): key = 'dqtest-{}'.format(uuid4()) assert Redis.set(key, '1') assert Redis.expire(key, 1) sleep(1.5) assert not Redis.exists(key)