summaryrefslogtreecommitdiffstats
path: root/tests/cli_tests/test_command_input.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cli_tests/test_command_input.py')
-rw-r--r--tests/cli_tests/test_command_input.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/cli_tests/test_command_input.py b/tests/cli_tests/test_command_input.py
new file mode 100644
index 0000000..f0aab4a
--- /dev/null
+++ b/tests/cli_tests/test_command_input.py
@@ -0,0 +1,77 @@
+import os
+
+from packaging.version import parse as version_parse
+import pytest
+
+
+def test_wrong_select_db_index(cli):
+ cli.sendline("select 1")
+ cli.expect(["OK", "127.0.0.1"])
+
+ cli.sendline("select 128")
+ cli.expect(["DB index is out of range", "127.0.0.1:6379[1]>"])
+
+ 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"
+
+ cli.sendline("select abc")
+ cli.expect([text, "127.0.0.1:6379[1]>"])
+
+ cli.sendline("select 15")
+ cli.expect("OK")
+
+
+def test_set_command_with_shash(clean_redis, cli):
+ cli.sendline("set a \\hello\\") # legal redis command
+ cli.expect("OK")
+
+ cli.sendline("get a")
+ cli.expect(r"hello")
+
+
+def test_enter_key_binding(clean_redis, cli):
+ cli.send("set")
+ cli.expect("set")
+ cli.send("\033[B") # down
+ cli.sendline() # enter
+
+ cli.sendline(" a 'hello'")
+ cli.expect("OK")
+
+ cli.sendline("get a")
+ cli.expect(r"hello")
+
+
+@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("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")
+ cli.expect(r"\*{11}")
+
+
+def test_hello_command_is_not_supported(cli):
+ cli.sendline("hello 3")
+ cli.expect("IRedis currently not support RESP3")
+
+
+@pytest.mark.xfail(reason="unstable, maybe due to github action's signal handling")
+def test_abort_reading_connection(cli):
+ cli.sendline("blpop mylist 30")
+ cli.send(chr(3))
+ cli.expect(
+ r"KeyboardInterrupt received! User canceled reading response!", timeout=10
+ )
+
+ cli.sendline("set foo bar")
+ cli.expect("OK")
+ cli.sendline("get foo")
+ cli.expect("bar")