Merging upstream version 1.9.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
7ac9951505
commit
db5ed8b1cc
131 changed files with 3811 additions and 826 deletions
0
tests/unittests/__init__.py
Normal file
0
tests/unittests/__init__.py
Normal file
|
@ -26,9 +26,15 @@ def test_command_cluster_count_failure_reports(judge_command):
|
|||
)
|
||||
judge_command("cluster count-failure-reports 1 2 3 4", None)
|
||||
judge_command("cluster count-failure-reports 1 a", None)
|
||||
judge_command("cluster count-failure-reports a", None)
|
||||
judge_command(
|
||||
"cluster count-failure-reports a",
|
||||
{"command": "cluster count-failure-reports", "node": "a"},
|
||||
)
|
||||
judge_command("cluster count-failure-reports a 2", None)
|
||||
judge_command("cluster count-failure-reports abc", None)
|
||||
judge_command(
|
||||
"cluster count-failure-reports abc",
|
||||
{"command": "cluster count-failure-reports", "node": "abc"},
|
||||
)
|
||||
|
||||
|
||||
def test_command_cluster_countkeysinslot(judge_command):
|
||||
|
@ -88,9 +94,22 @@ def test_command_cluster_forget(judge_command):
|
|||
)
|
||||
judge_command("cluster forget 1 2 3 4", None)
|
||||
judge_command("cluster forget 1 a", None)
|
||||
judge_command("cluster forget a", None)
|
||||
judge_command("cluster forget a", {"command": "cluster forget", "node": "a"})
|
||||
judge_command("cluster forget a 2", None)
|
||||
judge_command("cluster forget abc", None)
|
||||
judge_command(
|
||||
"cluster forget abc",
|
||||
{
|
||||
"command": "cluster forget",
|
||||
"node": "abc",
|
||||
},
|
||||
)
|
||||
judge_command(
|
||||
"cluster forget 07c37dfeb235213a872192d90877d0cd55635b91",
|
||||
{
|
||||
"command": "cluster forget",
|
||||
"node": "07c37dfeb235213a872192d90877d0cd55635b91",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_command_cluster_getkeysinslot(judge_command):
|
||||
|
@ -208,6 +227,15 @@ def test_command_cluster_set_slot(judge_command):
|
|||
"node": "123123",
|
||||
},
|
||||
)
|
||||
judge_command(
|
||||
"cluster setslot 123 node e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca",
|
||||
{
|
||||
"command": "cluster setslot",
|
||||
"slot": "123",
|
||||
"slotsubcmd": "node",
|
||||
"node": "e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca",
|
||||
},
|
||||
)
|
||||
judge_command(
|
||||
"cluster setslot 123 MIGRATING 123123",
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@ from iredis.config import config, load_config_files
|
|||
from iredis.completers import IRedisCompleter
|
||||
from iredis.entry import Rainbow, prompt_message
|
||||
from iredis.exceptions import NotSupport
|
||||
from ..helpers import formatted_text_rematch
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -258,19 +259,15 @@ def test_peek_string(iredis_client, clean_redis):
|
|||
clean_redis.set("foo", "bar")
|
||||
peek_result = list(iredis_client.do_peek("foo"))
|
||||
|
||||
assert peek_result == [
|
||||
FormattedText(
|
||||
[
|
||||
("class:dockey", "key: "),
|
||||
("", "string (embstr) mem: 50 bytes, ttl: -1"),
|
||||
("", "\n"),
|
||||
("class:dockey", "strlen: "),
|
||||
("", "3"),
|
||||
("", "\n"),
|
||||
("class:dockey", "value: "),
|
||||
("", '"bar"'),
|
||||
]
|
||||
)
|
||||
assert peek_result[0][0] == ("class:dockey", "key: ")
|
||||
assert re.match(r"string \(embstr\) mem: \d+ bytes, ttl: -1", peek_result[0][1][1])
|
||||
assert peek_result[0][2:] == [
|
||||
("", "\n"),
|
||||
("class:dockey", "strlen: "),
|
||||
("", "3"),
|
||||
("", "\n"),
|
||||
("class:dockey", "value: "),
|
||||
("", '"bar"'),
|
||||
]
|
||||
|
||||
|
||||
|
@ -278,39 +275,40 @@ def test_peek_list_fetch_all(iredis_client, clean_redis):
|
|||
clean_redis.lpush("mylist", *[f"hello-{index}" for index in range(5)])
|
||||
peek_result = list(iredis_client.do_peek("mylist"))
|
||||
|
||||
assert peek_result == [
|
||||
formatted_text_rematch(
|
||||
peek_result[0],
|
||||
FormattedText(
|
||||
[
|
||||
("class:dockey", "key: "),
|
||||
("", "list (quicklist) mem: 176 bytes, ttl: -1"),
|
||||
("", r"list \(quicklist\) mem: \d+ bytes, ttl: -1"),
|
||||
("", "\n"),
|
||||
("class:dockey", "llen: "),
|
||||
("", "5"),
|
||||
("", "\n"),
|
||||
("class:dockey", "elements: "),
|
||||
("", "\n"),
|
||||
("", "1)"),
|
||||
("", r"1\)"),
|
||||
("", " "),
|
||||
("class:string", '"hello-4"'),
|
||||
("", "\n"),
|
||||
("", "2)"),
|
||||
("", r"2\)"),
|
||||
("", " "),
|
||||
("class:string", '"hello-3"'),
|
||||
("", "\n"),
|
||||
("", "3)"),
|
||||
("", r"3\)"),
|
||||
("", " "),
|
||||
("class:string", '"hello-2"'),
|
||||
("", "\n"),
|
||||
("", "4)"),
|
||||
("", r"4\)"),
|
||||
("", " "),
|
||||
("class:string", '"hello-1"'),
|
||||
("", "\n"),
|
||||
("", "5)"),
|
||||
("", r"5\)"),
|
||||
("", " "),
|
||||
("class:string", '"hello-0"'),
|
||||
]
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def test_peek_list_fetch_part(iredis_client, clean_redis):
|
||||
|
@ -338,18 +336,21 @@ def test_peek_zset_fetch_all(iredis_client, clean_redis):
|
|||
"myzset", dict(zip([f"hello-{index}" for index in range(3)], range(3)))
|
||||
)
|
||||
peek_result = list(iredis_client.do_peek("myzset"))
|
||||
assert peek_result[0][0:9] == FormattedText(
|
||||
[
|
||||
("class:dockey", "key: "),
|
||||
("", "zset (ziplist) mem: 92 bytes, ttl: -1"),
|
||||
("", "\n"),
|
||||
("class:dockey", "zcount: "),
|
||||
("", "3"),
|
||||
("", "\n"),
|
||||
("class:dockey", "members: "),
|
||||
("", "\n"),
|
||||
("", "1)"),
|
||||
]
|
||||
formatted_text_rematch(
|
||||
peek_result[0][0:9],
|
||||
FormattedText(
|
||||
[
|
||||
("class:dockey", "key: "),
|
||||
("", r"zset \(ziplist\) mem: \d+ bytes, ttl: -1"),
|
||||
("", "\n"),
|
||||
("class:dockey", "zcount: "),
|
||||
("", "3"),
|
||||
("", "\n"),
|
||||
("class:dockey", "members: "),
|
||||
("", "\n"),
|
||||
("", r"1\)"),
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -358,17 +359,20 @@ def test_peek_zset_fetch_part(iredis_client, clean_redis):
|
|||
"myzset", dict(zip([f"hello-{index}" for index in range(40)], range(40)))
|
||||
)
|
||||
peek_result = list(iredis_client.do_peek("myzset"))
|
||||
assert peek_result[0][0:8] == FormattedText(
|
||||
[
|
||||
("class:dockey", "key: "),
|
||||
("", "zset (ziplist) mem: 556 bytes, ttl: -1"),
|
||||
("", "\n"),
|
||||
("class:dockey", "zcount: "),
|
||||
("", "40"),
|
||||
("", "\n"),
|
||||
("class:dockey", "members (first 40): "),
|
||||
("", "\n"),
|
||||
]
|
||||
formatted_text_rematch(
|
||||
peek_result[0][0:8],
|
||||
FormattedText(
|
||||
[
|
||||
("class:dockey", "key: "),
|
||||
("", r"zset \(ziplist\) mem: \d+ bytes, ttl: -1"),
|
||||
("", "\n"),
|
||||
("class:dockey", "zcount: "),
|
||||
("", "40"),
|
||||
("", "\n"),
|
||||
("class:dockey", r"members \(first 40\): "),
|
||||
("", "\n"),
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -395,10 +399,12 @@ def test_peek_stream(iredis_client, clean_redis):
|
|||
clean_redis.xadd("mystream", {"foo": "bar", "hello": "world"})
|
||||
peek_result = list(iredis_client.do_peek("mystream"))
|
||||
|
||||
assert peek_result[0][0:18] == FormattedText(
|
||||
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]
|
||||
)
|
||||
assert peek_result[0][2:18] == FormattedText(
|
||||
[
|
||||
("class:dockey", "key: "),
|
||||
("", "stream (unknown) mem: 601 bytes, ttl: -1"),
|
||||
("", "\n"),
|
||||
("class:dockey", "XINFO: "),
|
||||
("", "\n"),
|
||||
|
|
|
@ -484,3 +484,9 @@ def test_render_bytes(config):
|
|||
|
||||
def test_render_bytes_raw(config):
|
||||
assert renders.OutputRender.render_raw(b"bytes\n") == b"bytes\n"
|
||||
|
||||
|
||||
def test_render_help(config):
|
||||
assert renders.OutputRender.render_help([b"foo", b"bar"]) == FormattedText(
|
||||
[("class:string", "foo\nbar")]
|
||||
)
|
||||
|
|
|
@ -53,11 +53,11 @@ def test_timer():
|
|||
(r""" "hello\"world" """, ['hello"world']),
|
||||
(r"''", [""]), # set foo "" is a legal command
|
||||
(r'""', [""]), # set foo "" is a legal command
|
||||
(r"\\", ["\\\\"]), # blackslash are legal
|
||||
("\\hello\\", ["\\hello\\"]), # blackslash are legal
|
||||
(r"\\", ["\\\\"]), # backslash are legal
|
||||
("\\hello\\", ["\\hello\\"]), # backslash are legal
|
||||
],
|
||||
)
|
||||
def test_stipe_quote_escaple_in_quote(test_input, expected):
|
||||
def test_stripe_quote_escape_in_quote(test_input, expected):
|
||||
assert list(strip_quote_args(test_input)) == expected
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue