# Path: aredis/exceptions.py
# class RedisClusterException(Exception):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# class DataError(RedisError):
#     pass
# 
# class RedisError(Exception):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# def iteritems(x):
#     return iter(x.items())
# 
# def iterkeys(x):
#     return iter(x.keys())
# 
# def itervalues(x):
#     return iter(x.values())
# 
# Path: aredis/commands/server.py
# def parse_info(response):
#     """Parses the result of Redis's INFO command into a Python dict"""
#     info = {}
#     response = nativestr(response)
# 
#     def get_value(value):
#         if ',' not in value or '=' not in value:
#             try:
#                 if '.' in value:
#                     return float(value)
#                 else:
#                     return int(value)
#             except ValueError:
#                 return value
#         else:
#             sub_dict = {}
#             for item in value.split(','):
#                 k, v = item.rsplit('=', 1)
#                 sub_dict[k] = get_value(v)
#             return sub_dict
# 
#     for line in response.splitlines():
#         if line and not line.startswith('#'):
#             if line.find(':') != -1:
#                 key, value = line.split(':', 1)
#                 info[key] = get_value(value)
#             else:
#                 # if the line isn't splittable, append it to the "__raw__" key
#                 info.setdefault('__raw__', []).append(line)
# 
#     return info
# 
# Path: tests/cluster/conftest.py
# def skip_if_server_version_lt(min_version):
#     """
#     """
#     versions = get_versions()
#     for version in versions.values():
#         if StrictVersion(version) < StrictVersion(min_version):
#             return pytest.mark.skipif(True, reason="")
#     return pytest.mark.skipif(False, reason="")
# 
# def skip_if_redis_py_version_lt(min_version):
#     """
#     """
#     import aredis
#     version = aredis.__version__
#     if StrictVersion(version) < StrictVersion(min_version):
#         return pytest.mark.skipif(True, reason="")
#     return pytest.mark.skipif(False, reason="")


import datetime
import re
import time
import pytest
from string import ascii_letters
from aredis.exceptions import RedisClusterException, ResponseError, DataError, RedisError
from aredis.utils import b, iteritems, iterkeys, itervalues
from aredis.commands.server import parse_info
from tests.cluster.conftest import skip_if_server_version_lt, skip_if_redis_py_version_lt

    @pytest.mark.asyncio
    async def test_config_set(self, r):
        assert await r.config_set('dbfilename', 'redis_py_test.rdb')
        config = await r.config_get()
        for server, config in config.items():
            assert config['dbfilename'] == 'redis_py_test.rdb'

    @pytest.mark.asyncio
    async def test_echo(self, r):
        echo = await r.echo('foo bar')
        for server, res in echo.items():
            assert res == b('foo bar')

    @pytest.mark.asyncio
    async def test_object(self, r):
        await r.flushdb()
        await r.set('a', 'foo')
        assert await r.object('refcount', 'a') == 1
        assert isinstance(await r.object('refcount', 'a'), int)
        # assert isinstance(await r.object('idletime', 'a'), int)
        # assert await r.object('encoding', 'a') in (b('raw'), b('embstr'))
        assert await r.object('idletime', 'invalid-key') is None

    @pytest.mark.asyncio
    async def test_ping(self, r):
        assert await r.ping()

    @pytest.mark.asyncio
    async def test_time(self, r):

# Path: aredis/exceptions.py
# class RedisClusterException(Exception):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# class DataError(RedisError):
#     pass
# 
# class RedisError(Exception):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# def iteritems(x):
#     return iter(x.items())
# 
# def iterkeys(x):
#     return iter(x.keys())
# 
# def itervalues(x):
#     return iter(x.values())
# 
# Path: aredis/commands/server.py
# def parse_info(response):
#     """Parses the result of Redis's INFO command into a Python dict"""
#     info = {}
#     response = nativestr(response)
# 
#     def get_value(value):
#         if ',' not in value or '=' not in value:
#             try:
#                 if '.' in value:
#                     return float(value)
#                 else:
#                     return int(value)
#             except ValueError:
#                 return value
#         else:
#             sub_dict = {}
#             for item in value.split(','):
#                 k, v = item.rsplit('=', 1)
#                 sub_dict[k] = get_value(v)
#             return sub_dict
# 
#     for line in response.splitlines():
#         if line and not line.startswith('#'):
#             if line.find(':') != -1:
#                 key, value = line.split(':', 1)
#                 info[key] = get_value(value)
#             else:
#                 # if the line isn't splittable, append it to the "__raw__" key
#                 info.setdefault('__raw__', []).append(line)
# 
#     return info
# 
# Path: tests/cluster/conftest.py
# def skip_if_server_version_lt(min_version):
#     """
#     """
#     versions = get_versions()
#     for version in versions.values():
#         if StrictVersion(version) < StrictVersion(min_version):
#             return pytest.mark.skipif(True, reason="")
#     return pytest.mark.skipif(False, reason="")
# 
# def skip_if_redis_py_version_lt(min_version):
#     """
#     """
#     import aredis
#     version = aredis.__version__
#     if StrictVersion(version) < StrictVersion(min_version):
#         return pytest.mark.skipif(True, reason="")
#     return pytest.mark.skipif(False, reason="")


# Path: tests/cluster/test_commands.py
import datetime
import re
import time
import pytest
from string import ascii_letters
from aredis.exceptions import RedisClusterException, ResponseError, DataError, RedisError
from aredis.utils import b, iteritems, iterkeys, itervalues
from aredis.commands.server import parse_info
from tests.cluster.conftest import skip_if_server_version_lt, skip_if_redis_py_version_lt


    @pytest.mark.asyncio
    async def test_config_set(self, r):
        assert await r.config_set('dbfilename', 'redis_py_test.rdb')
        config = await r.config_get()
        for server, config in config.items():
            assert config['dbfilename'] == 'redis_py_test.rdb'

    @pytest.mark.asyncio
    async def test_echo(self, r):
        echo = await r.echo('foo bar')
        for server, res in echo.items():
            assert res == b('foo bar')

    @pytest.mark.asyncio
    async def test_object(self, r):
        await r.flushdb()
        await r.set('a', 'foo')
        assert await r.object('refcount', 'a') == 1
        assert isinstance(await r.object('refcount', 'a'), int)
        # assert isinstance(await r.object('idletime', 'a'), int)
        # assert await r.object('encoding', 'a') in (b('raw'), b('embstr'))
        assert await r.object('idletime', 'invalid-key') is None

    @pytest.mark.asyncio
    async def test_ping(self, r):
        assert await r.ping()

    @pytest.mark.asyncio
    async def test_time(self, r):

        await r.flushdb()