Debian Codegraph @

tests/cli_tests/test_warning.py

raw
1 from iredis.warning import is_dangerous
2
3
4 def test_is_dangerous():
5 assert is_dangerous("KEYS") == (
6 True,
7 "KEYS will hang redis server, use SCAN instead",
8 )
9
10
11 def test_warning_for_dangerous_command(cli):
12 cli.sendline("config set save '900 1'")
13 cli.expect("Do you want to proceed?")
14 cli.sendline("yes")
15
16 cli.sendline("config get save")
17 cli.expect("900 1")
18
19
20 def test_warnings_in_raw_mode(clean_redis, raw_cli):
21 clean_redis.set("foo", "bar")
22 raw_cli.sendline("keys *")
23 raw_cli.expect("Do you want to proceed?")
24 raw_cli.sendline("y")
25 raw_cli.expect("foo")
26
27
28 def test_warnings_in_raw_mode_canceled(clean_redis, raw_cli):
29 clean_redis.set("foo", "bar")
30 raw_cli.sendline("keys *")
31 raw_cli.expect("Do you want to proceed?")
32 raw_cli.sendline("n")
33 # the f should never appeared
34 raw_cli.expect("Canceled![^f]+127.0.0.1")
35
36
37 def test_warnings_confirmed(clean_redis, cli):
38 clean_redis.set("foo", "bar")
39 cli.sendline("keys *")
40 cli.expect("Do you want to proceed?")
41 cli.sendline("y")
42 cli.expect("foo")
43
44
45 def test_warnings_canceled(clean_redis, cli):
46 clean_redis.set("foo", "bar")
47 cli.sendline("keys *")
48 cli.expect("Do you want to proceed?")
49 cli.sendline("n")
50 # the f should never appeared
51 cli.expect("Canceled![^f]+127.0.0.1")