summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordvora-h <67596500+dvora-h@users.noreply.github.com>2022-03-16 14:13:40 +0200
committerGitHub <noreply@github.com>2022-03-16 14:13:40 +0200
commit878e2f2cd961bab5bf00d9b98e4fc7d16d5acfe0 (patch)
tree7f9ff289dd74b9b1976097d418c6a27801ef5f40
parent95b32682b1924dcba4944ef383390c29aea18085 (diff)
downloadredis-py-878e2f2cd961bab5bf00d9b98e4fc7d16d5acfe0.tar.gz
Mark tests for redis-stack (#2052)
* mark tests for redis-stack * linters
-rw-r--r--tests/test_bloom.py10
-rw-r--r--tests/test_commands.py112
-rw-r--r--tests/test_scripting.py24
-rw-r--r--tox.ini2
4 files changed, 81 insertions, 67 deletions
diff --git a/tests/test_bloom.py b/tests/test_bloom.py
index a3e9e15..4c6779b 100644
--- a/tests/test_bloom.py
+++ b/tests/test_bloom.py
@@ -34,6 +34,11 @@ def test_create(client):
assert client.cms().initbydim("cmsDim", 100, 5)
assert client.cms().initbyprob("cmsProb", 0.01, 0.01)
assert client.topk().reserve("topk", 5, 100, 5, 0.9)
+
+
+@pytest.mark.redismod
+@pytest.mark.experimental
+def test_tdigest_create(client):
assert client.tdigest().create("tDigest", 100)
@@ -306,6 +311,7 @@ def test_topk_incrby(client):
# region Test T-Digest
@pytest.mark.redismod
+@pytest.mark.experimental
def test_tdigest_reset(client):
assert client.tdigest().create("tDigest", 10)
# reset on empty histogram
@@ -319,6 +325,7 @@ def test_tdigest_reset(client):
@pytest.mark.redismod
+@pytest.mark.experimental
def test_tdigest_merge(client):
assert client.tdigest().create("to-tDigest", 10)
assert client.tdigest().create("from-tDigest", 10)
@@ -334,6 +341,7 @@ def test_tdigest_merge(client):
@pytest.mark.redismod
+@pytest.mark.experimental
def test_tdigest_min_and_max(client):
assert client.tdigest().create("tDigest", 100)
# insert data-points into sketch
@@ -344,6 +352,7 @@ def test_tdigest_min_and_max(client):
@pytest.mark.redismod
+@pytest.mark.experimental
def test_tdigest_quantile(client):
assert client.tdigest().create("tDigest", 500)
# insert data-points into sketch
@@ -359,6 +368,7 @@ def test_tdigest_quantile(client):
@pytest.mark.redismod
+@pytest.mark.experimental
def test_tdigest_cdf(client):
assert client.tdigest().create("tDigest", 100)
# insert data-points into sketch
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 0c5be9e..de6bcea 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -626,11 +626,11 @@ class TestRedisCommands:
assert r.client_unpause() == b"OK"
@pytest.mark.onlynoncluster
- # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
- def test_client_no_evict(self, unstable_r):
- assert unstable_r.client_no_evict("ON") == "OK"
+ @skip_if_server_version_lt("7.0.0")
+ def test_client_no_evict(self, r):
+ assert r.client_no_evict("ON") == "OK"
with pytest.raises(TypeError):
- unstable_r.client_no_evict()
+ r.client_no_evict()
@pytest.mark.onlynoncluster
@skip_if_server_version_lt("3.2.0")
@@ -998,15 +998,15 @@ class TestRedisCommands:
assert r.get("b") is None
@pytest.mark.onlynoncluster
- # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
- def test_lcs(self, unstable_r):
- unstable_r.mset({"foo": "ohmytext", "bar": "mynewtext"})
- assert unstable_r.lcs("foo", "bar") == "mytext"
- assert unstable_r.lcs("foo", "bar", len=True) == 6
+ @skip_if_server_version_lt("7.0.0")
+ def test_lcs(self, r):
+ r.mset({"foo": "ohmytext", "bar": "mynewtext"})
+ assert r.lcs("foo", "bar") == "mytext"
+ assert r.lcs("foo", "bar", len=True) == 6
result = ["matches", [[[4, 7], [5, 8]]], "len", 6]
- assert unstable_r.lcs("foo", "bar", idx=True, minmatchlen=3) == result
+ assert r.lcs("foo", "bar", idx=True, minmatchlen=3) == result
with pytest.raises(redis.ResponseError):
- assert unstable_r.lcs("foo", "bar", len=True, idx=True)
+ assert r.lcs("foo", "bar", len=True, idx=True)
@skip_if_server_version_lt("2.6.0")
def test_dump_and_restore(self, r):
@@ -1671,27 +1671,27 @@ class TestRedisCommands:
assert r.brpoplpush("a", "b") == b""
@pytest.mark.onlynoncluster
- # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
- def test_blmpop(self, unstable_r):
- unstable_r.rpush("a", "1", "2", "3", "4", "5")
+ @skip_if_server_version_lt("7.0.0")
+ def test_blmpop(self, r):
+ r.rpush("a", "1", "2", "3", "4", "5")
res = ["a", ["1", "2"]]
- assert unstable_r.blmpop(1, "2", "b", "a", direction="LEFT", count=2) == res
+ assert r.blmpop(1, "2", "b", "a", direction="LEFT", count=2) == res
with pytest.raises(TypeError):
- unstable_r.blmpop(1, "2", "b", "a", count=2)
- unstable_r.rpush("b", "6", "7", "8", "9")
- assert unstable_r.blmpop(0, "2", "b", "a", direction="LEFT") == ["b", ["6"]]
- assert unstable_r.blmpop(1, "2", "foo", "bar", direction="RIGHT") is None
+ r.blmpop(1, "2", "b", "a", count=2)
+ r.rpush("b", "6", "7", "8", "9")
+ assert r.blmpop(0, "2", "b", "a", direction="LEFT") == ["b", ["6"]]
+ assert r.blmpop(1, "2", "foo", "bar", direction="RIGHT") is None
@pytest.mark.onlynoncluster
- # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
- def test_lmpop(self, unstable_r):
- unstable_r.rpush("foo", "1", "2", "3", "4", "5")
+ @skip_if_server_version_lt("7.0.0")
+ def test_lmpop(self, r):
+ r.rpush("foo", "1", "2", "3", "4", "5")
result = ["foo", ["1", "2"]]
- assert unstable_r.lmpop("2", "bar", "foo", direction="LEFT", count=2) == result
+ assert r.lmpop("2", "bar", "foo", direction="LEFT", count=2) == result
with pytest.raises(redis.ResponseError):
- unstable_r.lmpop("2", "bar", "foo", direction="up", count=2)
- unstable_r.rpush("bar", "a", "b", "c", "d")
- assert unstable_r.lmpop("2", "bar", "foo", direction="LEFT") == ["bar", ["a"]]
+ r.lmpop("2", "bar", "foo", direction="up", count=2)
+ r.rpush("bar", "a", "b", "c", "d")
+ assert r.lmpop("2", "bar", "foo", direction="LEFT") == ["bar", ["a"]]
def test_lindex(self, r):
r.rpush("a", "1", "2", "3")
@@ -1962,13 +1962,13 @@ class TestRedisCommands:
assert r.sinter("a", "b") == {b"2", b"3"}
@pytest.mark.onlynoncluster
- # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
- def test_sintercard(self, unstable_r):
- unstable_r.sadd("a", 1, 2, 3)
- unstable_r.sadd("b", 1, 2, 3)
- unstable_r.sadd("c", 1, 3, 4)
- assert unstable_r.sintercard(3, ["a", "b", "c"]) == 2
- assert unstable_r.sintercard(3, ["a", "b", "c"], limit=1) == 1
+ @skip_if_server_version_lt("7.0.0")
+ def test_sintercard(self, r):
+ r.sadd("a", 1, 2, 3)
+ r.sadd("b", 1, 2, 3)
+ r.sadd("c", 1, 3, 4)
+ assert r.sintercard(3, ["a", "b", "c"]) == 2
+ assert r.sintercard(3, ["a", "b", "c"], limit=1) == 1
@pytest.mark.onlynoncluster
def test_sinterstore(self, r):
@@ -2202,13 +2202,13 @@ class TestRedisCommands:
]
@pytest.mark.onlynoncluster
- # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
- def test_zintercard(self, unstable_r):
- unstable_r.zadd("a", {"a1": 1, "a2": 2, "a3": 1})
- unstable_r.zadd("b", {"a1": 2, "a2": 2, "a3": 2})
- unstable_r.zadd("c", {"a1": 6, "a3": 5, "a4": 4})
- assert unstable_r.zintercard(3, ["a", "b", "c"]) == 2
- assert unstable_r.zintercard(3, ["a", "b", "c"], limit=1) == 1
+ @skip_if_server_version_lt("7.0.0")
+ def test_zintercard(self, r):
+ r.zadd("a", {"a1": 1, "a2": 2, "a3": 1})
+ r.zadd("b", {"a1": 2, "a2": 2, "a3": 2})
+ r.zadd("c", {"a1": 6, "a3": 5, "a4": 4})
+ assert r.zintercard(3, ["a", "b", "c"]) == 2
+ assert r.zintercard(3, ["a", "b", "c"], limit=1) == 1
@pytest.mark.onlynoncluster
def test_zinterstore_sum(self, r):
@@ -2297,28 +2297,28 @@ class TestRedisCommands:
assert r.bzpopmin("c", timeout=1) == (b"c", b"c1", 100)
@pytest.mark.onlynoncluster
- # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
- def test_zmpop(self, unstable_r):
- unstable_r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
+ @skip_if_server_version_lt("7.0.0")
+ def test_zmpop(self, r):
+ r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
res = ["a", [["a1", "1"], ["a2", "2"]]]
- assert unstable_r.zmpop("2", ["b", "a"], min=True, count=2) == res
+ assert r.zmpop("2", ["b", "a"], min=True, count=2) == res
with pytest.raises(redis.DataError):
- unstable_r.zmpop("2", ["b", "a"], count=2)
- unstable_r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
- assert unstable_r.zmpop("2", ["b", "a"], max=True) == ["b", [["b1", "10"]]]
+ r.zmpop("2", ["b", "a"], count=2)
+ r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
+ assert r.zmpop("2", ["b", "a"], max=True) == ["b", [["b1", "10"]]]
@pytest.mark.onlynoncluster
- # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
- def test_bzmpop(self, unstable_r):
- unstable_r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
+ @skip_if_server_version_lt("7.0.0")
+ def test_bzmpop(self, r):
+ r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
res = ["a", [["a1", "1"], ["a2", "2"]]]
- assert unstable_r.bzmpop(1, "2", ["b", "a"], min=True, count=2) == res
+ assert r.bzmpop(1, "2", ["b", "a"], min=True, count=2) == res
with pytest.raises(redis.DataError):
- unstable_r.bzmpop(1, "2", ["b", "a"], count=2)
- unstable_r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
+ r.bzmpop(1, "2", ["b", "a"], count=2)
+ r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
res = ["b", [["b1", "10"]]]
- assert unstable_r.bzmpop(0, "2", ["b", "a"], max=True) == res
- assert unstable_r.bzmpop(1, "2", ["foo", "bar"], max=True) is None
+ assert r.bzmpop(0, "2", ["b", "a"], max=True) == res
+ assert r.bzmpop(1, "2", ["foo", "bar"], max=True) is None
def test_zrange(self, r):
r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
@@ -4481,12 +4481,14 @@ class TestRedisCommands:
assert r.replicaof("NO ONE")
assert r.replicaof("NO", "ONE")
+ @pytest.mark.replica
@skip_if_server_version_lt("2.8.0")
def test_sync(self, r):
r2 = redis.Redis(port=6380, decode_responses=False)
res = r2.sync()
assert b"REDIS" in res
+ @pytest.mark.replica
@skip_if_server_version_lt("2.8.0")
def test_psync(self, r):
r2 = redis.Redis(port=6380, decode_responses=False)
diff --git a/tests/test_scripting.py b/tests/test_scripting.py
index 4635f95..8f6a24c 100644
--- a/tests/test_scripting.py
+++ b/tests/test_scripting.py
@@ -65,13 +65,13 @@ class TestScripting:
# 2 * 3 == 6
assert r.eval(multiply_script, 1, "a", 3) == 6
- # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
+ @skip_if_server_version_lt("7.0.0")
@pytest.mark.onlynoncluster
- def test_eval_ro(self, unstable_r):
- unstable_r.set("a", "b")
- assert unstable_r.eval_ro("return redis.call('GET', KEYS[1])", 1, "a") == "b"
+ def test_eval_ro(self, r):
+ r.set("a", "b")
+ assert r.eval_ro("return redis.call('GET', KEYS[1])", 1, "a") == "b"
with pytest.raises(redis.ResponseError):
- unstable_r.eval_ro("return redis.call('DEL', KEYS[1])", 1, "a")
+ r.eval_ro("return redis.call('DEL', KEYS[1])", 1, "a")
def test_eval_msgpack(self, r):
msgpack_message_dumped = b"\x81\xa4name\xa3Joe"
@@ -154,15 +154,15 @@ class TestScripting:
# 2 * 3 == 6
assert r.evalsha(sha, 1, "a", 3) == 6
- # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
+ @skip_if_server_version_lt("7.0.0")
@pytest.mark.onlynoncluster
- def test_evalsha_ro(self, unstable_r):
- unstable_r.set("a", "b")
- get_sha = unstable_r.script_load("return redis.call('GET', KEYS[1])")
- del_sha = unstable_r.script_load("return redis.call('DEL', KEYS[1])")
- assert unstable_r.evalsha_ro(get_sha, 1, "a") == "b"
+ def test_evalsha_ro(self, r):
+ r.set("a", "b")
+ get_sha = r.script_load("return redis.call('GET', KEYS[1])")
+ del_sha = r.script_load("return redis.call('DEL', KEYS[1])")
+ assert r.evalsha_ro(get_sha, 1, "a") == "b"
with pytest.raises(redis.ResponseError):
- unstable_r.evalsha_ro(del_sha, 1, "a")
+ r.evalsha_ro(del_sha, 1, "a")
def test_evalsha_script_not_loaded(self, r):
r.set("a", 2)
diff --git a/tox.ini b/tox.ini
index e9174a6..1a3450b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -6,6 +6,8 @@ markers =
onlycluster: marks tests to be run only with cluster mode redis
onlynoncluster: marks tests to be run only with standalone redis
ssl: marker for only the ssl tests
+ replica: replica tests
+ experimental: run only experimental tests
[tox]
minversion = 3.2.0