Debian Codegraph @

tests/cli_tests/test_completer.py

raw
1 from packaging.version import parse as version_parse # noqa: F401
2 import pytest
3 import time
4
5
6 def test_integer_type_completer(cli):
7 cli.expect("127.0.0.1")
8 cli.send("BITFIELD meykey GET ")
9 time.sleep(0.3) # Wait for completion menu to appear
10 cli.expect(["i64", "u63", "u62"])
11 cli.sendline("u4 #0")
12 cli.expect("127.0.0.1")
13
14 cli.send("BITFIELD meykey GET ")
15 time.sleep(0.3)
16 cli.expect(["u4", "i64", "u63", "u62"])
17
18
19 def test_command_completion_when_a_command_is_another_command_substring(
20 cli, clean_redis
21 ):
22 cli.expect("127.0.0.1")
23 cli.send("set")
24 time.sleep(0.3)
25 cli.expect(["set", "setnx", "setex", "setbit", "setrange"])
26
27 cli.send("n")
28 time.sleep(0.3)
29 cli.expect("setnx")
30 cli.send("x")
31 time.sleep(0.3)
32 cli.expect("setnx")
33 cli.sendline("foo bar")
34 cli.expect(["1", "127.0.0.1"])
35
36 cli.send("setnx")
37 time.sleep(0.3)
38 cli.expect("foo")
39
40
41 def test_command_completion_when_space_command(cli, clean_redis):
42 cli.expect("127.0.0.1")
43
44 cli.send("command in")
45 time.sleep(0.3)
46 cli.expect("command info")
47
48
49 @pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) < version_parse('6')")
50 def test_username_completer(cli, iredis_client):
51 iredis_client.execute("acl setuser", "foo1")
52 iredis_client.execute("acl setuser", "bar2")
53
54 cli.expect("127.0.0.1")
55 cli.sendline("acl users")
56 cli.expect("foo1")
57
58 cli.send("acl deluser ")
59 time.sleep(0.3)
60 cli.expect("foo1")
61 cli.expect("bar2")