summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-20 09:20:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-20 09:20:47 +0000
commitec80aa0259c0c014bbbe496bd19a570be6fc6fae (patch)
tree7d516a3b07dd7a8e27bc492e47c26aaa30c3c159 /tests
parentAdding upstream version 1.13.1. (diff)
downloadiredis-ec80aa0259c0c014bbbe496bd19a570be6fc6fae.tar.xz
iredis-ec80aa0259c0c014bbbe496bd19a570be6fc6fae.zip
Adding upstream version 1.13.2.upstream/1.13.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/cli_tests/test_command_restore.py6
-rw-r--r--tests/cli_tests/test_pager.py7
-rw-r--r--tests/unittests/test_client.py10
-rw-r--r--tests/unittests/test_entry.py1
-rw-r--r--tests/unittests/test_markdown_doc_render.py2
5 files changed, 20 insertions, 6 deletions
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_pager.py b/tests/cli_tests/test_pager.py
index 38ced31..5a285a8 100644
--- a/tests/cli_tests/test_pager.py
+++ b/tests/cli_tests/test_pager.py
@@ -54,13 +54,18 @@ def test_using_pager_works_for_help():
child.expect(TEST_PAGER_BOUNDARY)
+long_list_type = "quicklist"
+if os.environ["REDIS_VERSION"] == "7":
+ long_list_type = "listpack"
+
+
def test_pager_works_for_peek(clean_redis):
for index in range(100):
clean_redis.lpush("long-list", f"value-{index}")
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)
diff --git a/tests/unittests/test_client.py b/tests/unittests/test_client.py
index 45f0054..77a48de 100644
--- a/tests/unittests/test_client.py
+++ b/tests/unittests/test_client.py
@@ -22,8 +22,12 @@ def completer():
zset_type = "ziplist"
+hash_type = "hashtable"
+list_type = "quicklist"
if os.environ["REDIS_VERSION"] == "7":
zset_type = "listpack"
+ hash_type = "listpack"
+ list_type = "listpack"
@pytest.mark.parametrize(
@@ -303,7 +307,7 @@ def test_peek_list_fetch_all(iredis_client, clean_redis):
FormattedText(
[
("class:dockey", "key: "),
- ("", r"list \(quicklist\) mem: \d+ bytes, ttl: -1"),
+ ("", rf"list \({list_type}\) mem: \d+ bytes, ttl: -1"),
("", "\n"),
("class:dockey", "llen: "),
("", "5"),
@@ -351,7 +355,7 @@ def test_peek_set_fetch_part(iredis_client, clean_redis):
peek_result = list(iredis_client.do_peek("myset"))
assert peek_result[0][0] == ("class:dockey", "key: ")
- assert peek_result[0][1][1].startswith("set (hashtable) mem: 2")
+ assert peek_result[0][1][1].startswith(f"set ({hash_type}) mem: ")
def test_peek_zset_fetch_all(iredis_client, clean_redis):
@@ -425,7 +429,7 @@ def test_peek_stream(iredis_client, clean_redis):
assert peek_result[0][0] == ("class:dockey", "key: ")
assert re.match(
- r"stream \((stream|unknown)\) mem: 6\d\d bytes, ttl: -1", peek_result[0][1][1]
+ r"stream \((stream|unknown)\) mem: \d+ bytes, ttl: -1", peek_result[0][1][1]
)
assert peek_result[0][2:18] == FormattedText(
[
diff --git a/tests/unittests/test_entry.py b/tests/unittests/test_entry.py
index 912aabf..e53861e 100644
--- a/tests/unittests/test_entry.py
+++ b/tests/unittests/test_entry.py
@@ -28,7 +28,6 @@ from iredis.utils import DSN
def test_command_entry_tty(is_tty, raw_arg_is_raw, final_config_is_raw, config):
# is tty + raw -> raw
with patch("sys.stdout.isatty") as patch_tty:
-
patch_tty.return_value = is_tty
if raw_arg_is_raw is None:
call = ["iredis"]
diff --git a/tests/unittests/test_markdown_doc_render.py b/tests/unittests/test_markdown_doc_render.py
index 0538299..0c66260 100644
--- a/tests/unittests/test_markdown_doc_render.py
+++ b/tests/unittests/test_markdown_doc_render.py
@@ -6,7 +6,7 @@ https://github.com/antirez/redis-doc/commit/02b3d1a345093c1794fd86273e9d516fffd3
"""
import pytest
-from importlib_resources import read_text
+from importlib.resources import read_text
from iredis.commands import commands_summary
from iredis.data import commands as commands_data