How to use the iredis.client.Client function in iredis

To help you get started, we’ve selected a few iredis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github laixintao / iredis / tests / test_client.py View on Github external
def test_get_server_verison_after_client():
    from iredis.config import config

    Client("127.0.0.1", "6379", None)
    assert config.version.startswith("5.")

    config.version = "Unknown"
    Client("127.0.0.1", "6379", None, get_info=False)
    assert config.version == "Unknown"
github laixintao / iredis / tests / test_client.py View on Github external
def test_patch_completer(completer):
    client = Client("127.0.0.1", "6379", None)
    client.pre_hook(
        "MGET foo bar hello world", "MGET", "foo bar hello world", completer
    )
    assert completer.completers["key"].words == ["world", "hello", "bar", "foo"]
    assert completer.completers["keys"].words == ["world", "hello", "bar", "foo"]
    client.pre_hook("GET bar", "GET", "bar", completer)
    assert completer.completers["keys"].words == ["bar", "world", "hello", "foo"]
github laixintao / iredis / tests / test_client.py View on Github external
def test_get_server_verison_after_client():
    from iredis.config import config

    Client("127.0.0.1", "6379", None)
    assert config.version.startswith("5.")

    config.version = "Unknown"
    Client("127.0.0.1", "6379", None, get_info=False)
    assert config.version == "Unknown"
github laixintao / iredis / tests / test_client.py View on Github external
def test_send_command(_input, command_name, expect_args):
    client = Client("127.0.0.1", "6379", None)
    client.execute_command_and_read_response = MagicMock()
    client.send_command(_input, None)
    args, kwargs = client.execute_command_and_read_response.call_args
    assert args == (None, command_name, *expect_args)
github laixintao / iredis / tests / test_client.py View on Github external
def test_do_help():
    from iredis.config import config

    client = Client("127.0.0.1", "6379", None)
    config.version = "5.0.0"
    resp = client.do_help("SET")
    assert resp[10] == ("", "1.0.0 (Avaiable on your redis-server: 5.0.0)")
    config.version = "2.0.0"
    resp = client.do_help("cluster", "addslots")
    assert resp[10] == ("", "3.0.0 (Not avaiable on your redis-server: 2.0.0)")
github laixintao / iredis / iredis / entry.py View on Github external
# invoke in non-standalone mode to gather args
    ctx = None
    try:
        ctx = gather_args.main(standalone_mode=False)
    except click.exceptions.NoSuchOption as nosuchoption:
        nosuchoption.show()
    except click.exceptions.BadOptionUsage as badoption:
        if badoption.option_name == "-h":
            # -h without host, is short command for --help
            # like redis-cli
            print_help_msg(gather_args)
        return
    if not ctx:  # called help
        return
    # redis client
    client = Client(
        ctx.params["h"],
        ctx.params["p"],
        ctx.params["n"],
        ctx.params["password"],
        config.decode,
        get_info=not ctx.params["no_info"],
    )
    if not sys.stdin.isatty():
        for line in sys.stdin.readlines():
            logger.debug(f"[Command stdin] {line}")
            answer = client.send_command(line, None)
            write_result(answer)
        return

    if ctx.params["cmd"]:  # no interactive mode
        answer = client.send_command(" ".join(ctx.params["cmd"]), None)