diff options
Diffstat (limited to 'tests/cli_tests/test_warning.py')
-rw-r--r-- | tests/cli_tests/test_warning.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/cli_tests/test_warning.py b/tests/cli_tests/test_warning.py new file mode 100644 index 0000000..402c51b --- /dev/null +++ b/tests/cli_tests/test_warning.py @@ -0,0 +1,51 @@ +from iredis.warning import is_dangerous + + +def test_is_dangerous(): + assert is_dangerous("KEYS") == ( + True, + "KEYS will hang redis server, use SCAN instead", + ) + + +def test_warning_for_dangerous_command(cli): + cli.sendline("config set save '900 1'") + cli.expect("Do you want to proceed?") + cli.sendline("yes") + + cli.sendline("config get save") + cli.expect("900 1") + + +def test_warnings_in_raw_mode(clean_redis, raw_cli): + clean_redis.set("foo", "bar") + raw_cli.sendline("keys *") + raw_cli.expect("Do you want to proceed?") + raw_cli.sendline("y") + raw_cli.expect("foo") + + +def test_warnings_in_raw_mode_canceled(clean_redis, raw_cli): + clean_redis.set("foo", "bar") + raw_cli.sendline("keys *") + raw_cli.expect("Do you want to proceed?") + raw_cli.sendline("n") + # the f should never appeared + raw_cli.expect("Canceled![^f]+127.0.0.1") + + +def test_warnings_confirmed(clean_redis, cli): + clean_redis.set("foo", "bar") + cli.sendline("keys *") + cli.expect("Do you want to proceed?") + cli.sendline("y") + cli.expect("foo") + + +def test_warnings_canceled(clean_redis, cli): + clean_redis.set("foo", "bar") + cli.sendline("keys *") + cli.expect("Do you want to proceed?") + cli.sendline("n") + # the f should never appeared + cli.expect("Canceled![^f]+127.0.0.1") |