예제 #1
0
def test_redis_exec_configuration(request: FixtureRequest,
                                  tmp_path_factory: TempPathFactory, parameter,
                                  config_option, value):
    """
    Check if RedisExecutor properly processes configuration options.

    Improperly set options won't be set in redis,
    and we won't be able to read it out of redis.
    """
    config = get_config(request)
    tmpdir = tmp_path_factory.mktemp(
        f"pytest-redis-test-test_redis_exec_configuration")
    redis_exec = RedisExecutor(
        executable=config["exec"],
        databases=4,
        redis_timeout=config["timeout"],
        loglevel=config["loglevel"],
        port=get_port(None),
        host=config["host"],
        timeout=30,
        datadir=tmpdir,
        **parameter,
    )
    with redis_exec:
        redis_client = redis.StrictRedis(redis_exec.host, redis_exec.port, 0)
        assert redis_client.config_get(config_option) == {config_option: value}
예제 #2
0
def test_not_existing_redis(request):
    """Check handling of misconfigured redis executable path."""
    config = get_config(request)
    with pytest.raises(RedisMisconfigured):
        RedisExecutor(
            '/not/redis/here/redis-server',
            databases=4,
            redis_timeout=config['timeout'],
            loglevel=config['loglevel'],
            logsdir=config['logsdir'],
            port=get_port(None),
            host=config['host'],
            timeout=30,
        ).start()
예제 #3
0
def test_too_long_unixsocket(request: FixtureRequest,
                             tmp_path_factory: TempPathFactory):
    """Check handling of misconfigured redis executable path."""
    config = get_config(request)
    tmpdir = tmp_path_factory.mktemp(f"x" * 110)
    with pytest.raises(UnixSocketTooLong):
        RedisExecutor(
            config["exec"],
            databases=4,
            redis_timeout=config["timeout"],
            loglevel=config["loglevel"],
            port=get_port(None),
            host=config["host"],
            timeout=30,
            datadir=tmpdir,
        ).start()
예제 #4
0
def test_not_existing_redis(request: FixtureRequest,
                            tmp_path_factory: TempPathFactory):
    """Check handling of misconfigured redis executable path."""
    config = get_config(request)
    tmpdir = tmp_path_factory.mktemp(
        f"pytest-redis-test-test_not_existing_redis")
    with pytest.raises(RedisMisconfigured):
        RedisExecutor(
            "/not/redis/here/redis-server",
            databases=4,
            redis_timeout=config["timeout"],
            loglevel=config["loglevel"],
            port=get_port(None),
            host=config["host"],
            timeout=30,
            datadir=tmpdir,
        ).start()
예제 #5
0
def test_old_redis_version(request: FixtureRequest,
                           tmp_path_factory: TempPathFactory, version):
    """Test how fixture behaves in case of old redis version."""
    config = get_config(request)
    tmpdir = tmp_path_factory.mktemp(
        f"pytest-redis-test-test_old_redis_version")
    with mock.patch("os.popen", lambda *args: StringIO(version)):
        with pytest.raises(RedisUnsupported):
            RedisExecutor(
                config["exec"],
                databases=4,
                redis_timeout=config["timeout"],
                loglevel=config["loglevel"],
                port=get_port(None),
                host=config["host"],
                timeout=30,
                datadir=tmpdir,
            ).start()
예제 #6
0
def test_old_redis_version(request, version):
    """Test how fixture behaves in case of old redis version."""
    config = get_config(request)
    with mock.patch(
            'os.popen',
            lambda *args: StringIO(version)
    ):
        with pytest.raises(RedisUnsupported):
            RedisExecutor(
                config['exec'],
                databases=4,
                redis_timeout=config['timeout'],
                loglevel=config['loglevel'],
                logsdir=config['logsdir'],
                port=get_port(None),
                host=config['host'],
                timeout=30,
            ).start()
예제 #7
0
def test_redis_exec(request, parameter):
    """
    Check if RedisExecutor properly starts with these configuration options.

    Incorrect options won't even start redis.
    """
    config = get_config(request)
    redis_exec = RedisExecutor(
        executable=config['exec'],
        databases=4,
        redis_timeout=config['timeout'],
        loglevel=config['loglevel'],
        logsdir=config['logsdir'],
        port=get_port(None),
        host=config['host'],
        timeout=30,
        **parameter
    )
    with redis_exec:
        assert redis_exec.running()
예제 #8
0
def test_redis_exec(request: FixtureRequest, tmp_path_factory: TempPathFactory,
                    parameter):
    """
    Check if RedisExecutor properly starts with these configuration options.

    Incorrect options won't even start redis.
    """
    config = get_config(request)
    tmpdir = tmp_path_factory.mktemp(f"pytest-redis-test-test_redis_exec")
    redis_exec = RedisExecutor(
        executable=config["exec"],
        databases=4,
        redis_timeout=config["timeout"],
        loglevel=config["loglevel"],
        port=get_port(None),
        host=config["host"],
        timeout=30,
        datadir=tmpdir,
        **parameter,
    )
    with redis_exec:
        assert redis_exec.running()
예제 #9
0
def test_redis_exec_configuration(request, parameter, config_option, value):
    """
    Check if RedisExecutor properly processes configuration options.

    Improperly set options won't be set in redis,
    and we won't be able to read it out of redis.
    """
    config = get_config(request)
    redis_exec = RedisExecutor(
        executable=config['exec'],
        databases=4,
        redis_timeout=config['timeout'],
        loglevel=config['loglevel'],
        logsdir=config['logsdir'],
        port=get_port(None),
        host=config['host'],
        timeout=30,
        **parameter
    )
    with redis_exec:
        redis_client = redis.StrictRedis(
            redis_exec.host, redis_exec.port, 0
        )
        assert redis_client.config_get(config_option) == {config_option: value}