dragonfly/tests/dragonfly/list_family_test.py
Vladislav b0537418bc
fix: use redis.asyncio instead of aioredis (#1206)
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2023-05-13 10:44:25 +03:00

23 lines
915 B
Python

import asyncio
from redis import asyncio as aioredis
import pytest
@pytest.mark.parametrize('index', range(50))
class TestBlPop:
async def async_blpop(client: aioredis.Redis):
return await client.blpop(
['list1{t}', 'list2{t}', 'list2{t}', 'list1{t}'], 0.5)
async def blpop_mult_keys(async_client: aioredis.Redis, key: str, val: str):
task = asyncio.create_task(TestBlPop.async_blpop(async_client))
await async_client.lpush(key, val)
result = await asyncio.wait_for(task, 3)
assert result[1] == val
watched = await async_client.execute_command('DEBUG WATCHED')
assert watched == ['awaked', [], 'watched', []]
async def test_blpop_multiple_keys(self, async_client: aioredis.Redis, index):
await TestBlPop.blpop_mult_keys(async_client, 'list1{t}', 'a')
await TestBlPop.blpop_mult_keys(async_client, 'list2{t}', 'b')