diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2023-11-04 18:52:12 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2023-11-04 18:52:12 +0000 |
commit | a596894f2d782b9df54c026696e55da1267f7936 (patch) | |
tree | e2696ad38feb91700ac875966e6aa0b30e732566 /tests/cli_tests | |
parent | Adding upstream version 1.13.1. (diff) | |
download | iredis-upstream/1.14.0.tar.xz iredis-upstream/1.14.0.zip |
Adding upstream version 1.14.0.upstream/1.14.0
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'tests/cli_tests')
-rw-r--r-- | tests/cli_tests/test_cli_start.py | 8 | ||||
-rw-r--r-- | tests/cli_tests/test_command_input.py | 8 | ||||
-rw-r--r-- | tests/cli_tests/test_command_restore.py | 6 | ||||
-rw-r--r-- | tests/cli_tests/test_completer.py | 3 | ||||
-rw-r--r-- | tests/cli_tests/test_pager.py | 14 |
5 files changed, 28 insertions, 11 deletions
diff --git a/tests/cli_tests/test_cli_start.py b/tests/cli_tests/test_cli_start.py index 8045947..819b24f 100644 --- a/tests/cli_tests/test_cli_start.py +++ b/tests/cli_tests/test_cli_start.py @@ -1,6 +1,8 @@ +from textwrap import dedent + +from packaging.version import parse as version_parse # noqa: F401 import pexpect import pytest -from textwrap import dedent def test_start_on_connection_error(): @@ -29,14 +31,14 @@ def test_short_help_option(config): c.close() -@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) != 5") +@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) != version_parse('5')") def test_server_version_in_starting_on5(): c = pexpect.spawn("iredis", timeout=2) c.expect("redis-server 5") c.close() -@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) != 6") +@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) != version_parse('6')") def test_server_version_in_starting_on6(): c = pexpect.spawn("iredis", timeout=2) c.expect("redis-server 6") diff --git a/tests/cli_tests/test_command_input.py b/tests/cli_tests/test_command_input.py index 75917cb..f0aab4a 100644 --- a/tests/cli_tests/test_command_input.py +++ b/tests/cli_tests/test_command_input.py @@ -1,4 +1,6 @@ import os + +from packaging.version import parse as version_parse import pytest @@ -9,7 +11,7 @@ def test_wrong_select_db_index(cli): cli.sendline("select 128") cli.expect(["DB index is out of range", "127.0.0.1:6379[1]>"]) - if int(os.environ["REDIS_VERSION"]) > 5: + if version_parse(os.environ["REDIS_VERSION"]) > version_parse("5"): text = "value is not an integer or out of range" else: text = "invalid DB index" @@ -42,14 +44,14 @@ def test_enter_key_binding(clean_redis, cli): cli.expect(r"hello") -@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) < 6") +@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) < version_parse('6')") def test_auth_hidden_password_with_username(clean_redis, cli): cli.send("auth default hello-world") cli.expect("default") cli.expect(r"\*{11}") -@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) > 5") +@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) > version_parse('5')") def test_auth_hidden_password(clean_redis, cli): cli.send("auth hello-world") cli.expect("auth") diff --git a/tests/cli_tests/test_command_restore.py b/tests/cli_tests/test_command_restore.py new file mode 100644 index 0000000..1c34405 --- /dev/null +++ b/tests/cli_tests/test_command_restore.py @@ -0,0 +1,6 @@ +def test_restore_command(clean_redis, cli): + cli.sendline(r'restore foo1 0 "\x00\x03bar\t\x006L\x18\xac\xba\xe0\x9e\xa6"') + cli.expect(["OK", "127.0.0.1"]) + + cli.sendline("get foo1") + cli.expect('"bar"') diff --git a/tests/cli_tests/test_completer.py b/tests/cli_tests/test_completer.py index 4ffd058..adf8040 100644 --- a/tests/cli_tests/test_completer.py +++ b/tests/cli_tests/test_completer.py @@ -1,3 +1,4 @@ +from packaging.version import parse as version_parse # noqa: F401 import pytest @@ -37,7 +38,7 @@ def test_command_completion_when_space_command(cli, clean_redis): cli.expect("command info") -@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) < 6") +@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) < version_parse('6')") def test_username_completer(cli, iredis_client): iredis_client.execute("acl setuser", "foo1") iredis_client.execute("acl setuser", "bar2") diff --git a/tests/cli_tests/test_pager.py b/tests/cli_tests/test_pager.py index 38ced31..c3f9fb0 100644 --- a/tests/cli_tests/test_pager.py +++ b/tests/cli_tests/test_pager.py @@ -1,10 +1,12 @@ # noqa: F541 +from contextlib import contextmanager import os -import sys -import pexpect import pathlib -from contextlib import contextmanager +import sys from textwrap import dedent +from packaging.version import parse as version_parse + +import pexpect TEST_IREDISRC = "/tmp/.iredisrc.test" @@ -22,6 +24,10 @@ env_pager_numbers = "{0} {1} {2}".format( TEST_PAGER_BOUNDARY_NUMBER, ) +long_list_type = "quicklist" +if version_parse(os.environ["REDIS_VERSION"]) >= version_parse("7"): + long_list_type = "listpack" + @contextmanager def pager_enabled_cli(): @@ -60,7 +66,7 @@ def test_pager_works_for_peek(clean_redis): with pager_enabled_cli() as child: child.sendline("peek long-list") child.expect(TEST_PAGER_BOUNDARY) - child.expect("(quicklist)") + child.expect(f"({long_list_type})") child.expect("value-1") child.expect(TEST_PAGER_BOUNDARY) |