summaryrefslogtreecommitdiffstats
path: root/tests/cli_tests/test_transaction.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-03-21 10:28:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-02-07 11:16:53 +0000
commit06cba6ccd165ca8b224797e37fccb9e63f026d77 (patch)
treee82f1bc439997ae296f2e74f8a64d84c5d95f140 /tests/cli_tests/test_transaction.py
parentInitial commit. (diff)
downloadiredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.tar.xz
iredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.zip
Adding upstream version 1.9.1.upstream/1.9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/cli_tests/test_transaction.py')
-rw-r--r--tests/cli_tests/test_transaction.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/cli_tests/test_transaction.py b/tests/cli_tests/test_transaction.py
new file mode 100644
index 0000000..b5c6b4e
--- /dev/null
+++ b/tests/cli_tests/test_transaction.py
@@ -0,0 +1,70 @@
+import pytest
+import pexpect
+
+
+def test_trasaction_rprompt(clean_redis, cli):
+ cli.sendline("multi")
+ cli.expect(["OK", "transaction", "127.0.0.1"])
+
+ cli.sendline("get foo")
+ cli.expect(["QUEUED", "127.0.0.1", "transaction"])
+
+ cli.sendline("set hello world")
+ cli.expect(["QUEUED", "127.0.0.1", "transaction"])
+
+ cli.sendline("ping")
+ cli.expect(["QUEUED", "127.0.0.1", "transaction"])
+
+ cli.sendline("EXEC")
+ cli.expect("(nil)")
+ cli.expect("OK")
+ cli.expect("PONG")
+ cli.expect("127.0.0.1")
+
+ with pytest.raises(pexpect.exceptions.TIMEOUT):
+ cli.expect("transaction")
+
+
+def test_trasaction_syntax_error(cli):
+ cli.sendline("multi")
+ cli.sendline("get foo 1")
+ cli.expect(["wrong number of arguments for 'get' command", "transaction"])
+
+ cli.sendline("EXEC")
+ cli.expect("Transaction discarded because of previous errors.")
+ with pytest.raises(pexpect.exceptions.TIMEOUT):
+ cli.expect("transaction")
+
+
+def test_trasaction_in_raw_mode(clean_redis, raw_cli):
+ clean_redis.set("foo", "bar")
+
+ raw_cli.sendline("multi")
+ raw_cli.expect(["OK", "transaction", "127.0.0.1"])
+
+ raw_cli.sendline("get foo")
+ raw_cli.expect(["QUEUED", "127.0.0.1", "transaction"])
+
+ raw_cli.sendline("EXEC")
+ raw_cli.expect("bar")
+ raw_cli.expect("127.0.0.1")
+
+ with pytest.raises(pexpect.exceptions.TIMEOUT):
+ raw_cli.expect("transaction")
+
+
+def test_exec_return_nil_when_using_watch(clean_redis, cli):
+ cli.sendline("watch foo")
+ cli.expect("OK")
+
+ cli.sendline("multi")
+ cli.expect("OK")
+
+ cli.sendline("get bar")
+ cli.expect("QUEUED")
+
+ # transaction will fail, return nil
+ clean_redis.set("foo", "hello!")
+
+ cli.sendline("exec")
+ cli.expect("(nil)")