# Path: aredis/pool.py
# def to_bool(value):
#     if value is None or value == '':
#         return None
#     if isinstance(value, str) and value.upper() in FALSE_STRINGS:
#         return False
#     return bool(value)
# 
# Path: aredis/exceptions.py
# class ConnectionError(RedisError):
#     pass
# 
# class RedisError(Exception):
#     pass
# 
# class BusyLoadingError(ConnectionError):
#     pass
# 
# class ReadOnlyError(ResponseError):
#     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 os
import pytest
import aredis
import re
import asyncio
        import warnings
        import ssl
from aredis.pool import to_bool
from aredis.exceptions import (ConnectionError, RedisError,
                               BusyLoadingError, ReadOnlyError)
from .conftest import skip_if_server_version_lt

    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_connection_idle_check(self, event_loop):
        rs = aredis.StrictRedis(host='127.0.0.1', port=6379, db=0,
                                max_idle_time=0.2, idle_check_interval=0.1)
        await rs.info()
        assert len(rs.connection_pool._available_connections) == 1
        assert len(rs.connection_pool._in_use_connections) == 0
        conn = rs.connection_pool._available_connections[0]
        last_active_at = conn.last_active_at
        await asyncio.sleep(0.3)
        assert len(rs.connection_pool._available_connections) == 0
        assert len(rs.connection_pool._in_use_connections) == 0
        assert last_active_at == conn.last_active_at
        assert conn._writer is None and conn._reader is None


class TestConnectionPoolURLParsing:
    def test_defaults(self):
        pool = aredis.ConnectionPool.from_url('redis://localhost')
        assert pool.connection_class == aredis.Connection
        assert pool.connection_kwargs == {
            'host': 'localhost',
            'port': 6379,
            'db': 0,
            'password': None,
        }

    def test_hostname(self):
        pool = aredis.ConnectionPool.from_url('redis://myhost')

# Path: aredis/pool.py
# def to_bool(value):
#     if value is None or value == '':
#         return None
#     if isinstance(value, str) and value.upper() in FALSE_STRINGS:
#         return False
#     return bool(value)
# 
# Path: aredis/exceptions.py
# class ConnectionError(RedisError):
#     pass
# 
# class RedisError(Exception):
#     pass
# 
# class BusyLoadingError(ConnectionError):
#     pass
# 
# class ReadOnlyError(ResponseError):
#     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_connection_pool.py
import os
import pytest
import aredis
import re
import asyncio
        import warnings
        import ssl
from aredis.pool import to_bool
from aredis.exceptions import (ConnectionError, RedisError,
                               BusyLoadingError, ReadOnlyError)
from .conftest import skip_if_server_version_lt


    @pytest.mark.asyncio(forbid_global_loop=True)
    async def test_connection_idle_check(self, event_loop):
        rs = aredis.StrictRedis(host='127.0.0.1', port=6379, db=0,
                                max_idle_time=0.2, idle_check_interval=0.1)
        await rs.info()
        assert len(rs.connection_pool._available_connections) == 1
        assert len(rs.connection_pool._in_use_connections) == 0
        conn = rs.connection_pool._available_connections[0]
        last_active_at = conn.last_active_at
        await asyncio.sleep(0.3)
        assert len(rs.connection_pool._available_connections) == 0
        assert len(rs.connection_pool._in_use_connections) == 0
        assert last_active_at == conn.last_active_at
        assert conn._writer is None and conn._reader is None


class TestConnectionPoolURLParsing:
    def test_defaults(self):
        pool = aredis.ConnectionPool.from_url('redis://localhost')
        assert pool.connection_class == aredis.Connection
        assert pool.connection_kwargs == {
            'host': 'localhost',
            'port': 6379,
            'db': 0,
            'password': None,
        }

    def test_hostname(self):
        pool = aredis.ConnectionPool.from_url('redis://myhost')

        assert pool.connection_class == aredis.Connection