# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# Path: tests/client/conftest.py
# def skip_if_server_version_lt(min_version):
#     loop = asyncio.get_event_loop()
#     version = StrictVersion(loop.run_until_complete(get_version()))
#     check = version < StrictVersion(min_version)
#     return pytest.mark.skipif(check, reason="")


import pytest
import aredis
from aredis.exceptions import RedisError, ResponseError
from tests.client.conftest import skip_if_server_version_lt
        await r.flushdb()
        for idx in range(1, 10):
            await r.xadd('test_stream', {'k1': 'v1', 'k2': 1}, stream_id=idx)
        entries = await r.xread(count=5, block=10, test_stream='0')
        assert len(entries[b'test_stream']) == 5
        entries = await r.xread(count=10, block=10, test_stream='$')
        assert not entries
        entries = await r.xread(count=10, block=10, test_stream='2')
        assert entries and len(entries[b'test_stream']) == 7
        assert entries[b'test_stream'][0] == (b'3-0', {b'k1': b'v1', b'k2': b'1'})

    @skip_if_server_version_lt('4.9.103')
    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_xreadgroup(self, r):
        await r.flushdb()
        for idx in range(1, 10):
            await r.xadd('test_stream', {'k1': 'v1', 'k2': 1}, stream_id=idx)
        # read from group does not exist
        with pytest.raises(ResponseError) as exc:
            await r.xreadgroup('wrong_group', 'lalala', count=10, block=10, test_stream='1')
        assert await r.xgroup_create('test_stream', 'test_group', '0') is True
        entries = await r.xreadgroup('test_group', 'consumer1', count=5, test_stream='>')
        assert len(entries[b'test_stream']) == 5

    @skip_if_server_version_lt('4.9.103')
    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_xgroup_create(self, r):
        await r.flushdb()
        for idx in range(1, 10):
            await r.xadd('test_stream', {'k1': 'v1', 'k2': 1}, stream_id=idx)

# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# Path: tests/client/conftest.py
# def skip_if_server_version_lt(min_version):
#     loop = asyncio.get_event_loop()
#     version = StrictVersion(loop.run_until_complete(get_version()))
#     check = version < StrictVersion(min_version)
#     return pytest.mark.skipif(check, reason="")


# Path: tests/client/test_streams.py
import pytest
import aredis
from aredis.exceptions import RedisError, ResponseError
from tests.client.conftest import skip_if_server_version_lt

        await r.flushdb()
        for idx in range(1, 10):
            await r.xadd('test_stream', {'k1': 'v1', 'k2': 1}, stream_id=idx)
        entries = await r.xread(count=5, block=10, test_stream='0')
        assert len(entries[b'test_stream']) == 5
        entries = await r.xread(count=10, block=10, test_stream='$')
        assert not entries
        entries = await r.xread(count=10, block=10, test_stream='2')
        assert entries and len(entries[b'test_stream']) == 7
        assert entries[b'test_stream'][0] == (b'3-0', {b'k1': b'v1', b'k2': b'1'})

    @skip_if_server_version_lt('4.9.103')
    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_xreadgroup(self, r):
        await r.flushdb()
        for idx in range(1, 10):
            await r.xadd('test_stream', {'k1': 'v1', 'k2': 1}, stream_id=idx)
        # read from group does not exist
        with pytest.raises(ResponseError) as exc:
            await r.xreadgroup('wrong_group', 'lalala', count=10, block=10, test_stream='1')
        assert await r.xgroup_create('test_stream', 'test_group', '0') is True
        entries = await r.xreadgroup('test_group', 'consumer1', count=5, test_stream='>')
        assert len(entries[b'test_stream']) == 5

    @skip_if_server_version_lt('4.9.103')
    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_xgroup_create(self, r):
        await r.flushdb()
        for idx in range(1, 10):
            await r.xadd('test_stream', {'k1': 'v1', 'k2': 1}, stream_id=idx)

        with pytest.raises(ResponseError):