summaryrefslogtreecommitdiff
path: root/tests/test_pipeline.py
diff options
context:
space:
mode:
authorChayim <chayim@users.noreply.github.com>2021-09-01 17:09:41 +0300
committerGitHub <noreply@github.com>2021-09-01 17:09:41 +0300
commitfebede19423c95515a7548cd73aa1a90c639ba1f (patch)
tree969d634fc1416bab3e08d38c7dddf74597e793fc /tests/test_pipeline.py
parentb6ecd0d6b7e6848dd085c3644ed31598fb1c9f83 (diff)
downloadredis-py-febede19423c95515a7548cd73aa1a90c639ba1f.tar.gz
Pipeline DISCARD support (#1565)
closes #1539 Part of #1546
Diffstat (limited to 'tests/test_pipeline.py')
-rw-r--r--tests/test_pipeline.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py
index 9bc4a9f..08bd40b 100644
--- a/tests/test_pipeline.py
+++ b/tests/test_pipeline.py
@@ -1,7 +1,7 @@
import pytest
import redis
-from .conftest import wait_for_command
+from .conftest import wait_for_command, skip_if_server_version_lt
class TestPipeline:
@@ -353,3 +353,29 @@ class TestPipeline:
assert pipe == pipe2
assert response == [True, [0, 0, 15, 15, 14], b'1']
+
+ @skip_if_server_version_lt('2.0.0')
+ def test_pipeline_discard(self, r):
+
+ # empty pipeline should raise an error
+ with r.pipeline() as pipe:
+ pipe.set('key', 'someval')
+ pipe.discard()
+ with pytest.raises(redis.exceptions.ResponseError):
+ pipe.execute()
+
+ # setting a pipeline and discarding should do the same
+ with r.pipeline() as pipe:
+ pipe.set('key', 'someval')
+ pipe.set('someotherkey', 'val')
+ response = pipe.execute()
+ pipe.set('key', 'another value!')
+ pipe.discard()
+ pipe.set('key', 'another vae!')
+ with pytest.raises(redis.exceptions.ResponseError):
+ pipe.execute()
+
+ pipe.set('foo', 'bar')
+ response = pipe.execute()
+ assert response[0]
+ assert r.get('foo') == b'bar'