Skip to content

Commit 878e2f2

Browse files
authored
Mark tests for redis-stack (#2052)
* mark tests for redis-stack * linters
1 parent 95b3268 commit 878e2f2

File tree

4 files changed

+81
-67
lines changed

4 files changed

+81
-67
lines changed

tests/test_bloom.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def test_create(client):
3434
assert client.cms().initbydim("cmsDim", 100, 5)
3535
assert client.cms().initbyprob("cmsProb", 0.01, 0.01)
3636
assert client.topk().reserve("topk", 5, 100, 5, 0.9)
37+
38+
39+
@pytest.mark.redismod
40+
@pytest.mark.experimental
41+
def test_tdigest_create(client):
3742
assert client.tdigest().create("tDigest", 100)
3843

3944

@@ -306,6 +311,7 @@ def test_topk_incrby(client):
306311

307312
# region Test T-Digest
308313
@pytest.mark.redismod
314+
@pytest.mark.experimental
309315
def test_tdigest_reset(client):
310316
assert client.tdigest().create("tDigest", 10)
311317
# reset on empty histogram
@@ -319,6 +325,7 @@ def test_tdigest_reset(client):
319325

320326

321327
@pytest.mark.redismod
328+
@pytest.mark.experimental
322329
def test_tdigest_merge(client):
323330
assert client.tdigest().create("to-tDigest", 10)
324331
assert client.tdigest().create("from-tDigest", 10)
@@ -334,6 +341,7 @@ def test_tdigest_merge(client):
334341

335342

336343
@pytest.mark.redismod
344+
@pytest.mark.experimental
337345
def test_tdigest_min_and_max(client):
338346
assert client.tdigest().create("tDigest", 100)
339347
# insert data-points into sketch
@@ -344,6 +352,7 @@ def test_tdigest_min_and_max(client):
344352

345353

346354
@pytest.mark.redismod
355+
@pytest.mark.experimental
347356
def test_tdigest_quantile(client):
348357
assert client.tdigest().create("tDigest", 500)
349358
# insert data-points into sketch
@@ -359,6 +368,7 @@ def test_tdigest_quantile(client):
359368

360369

361370
@pytest.mark.redismod
371+
@pytest.mark.experimental
362372
def test_tdigest_cdf(client):
363373
assert client.tdigest().create("tDigest", 100)
364374
# insert data-points into sketch

tests/test_commands.py

Lines changed: 57 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -626,11 +626,11 @@ def test_client_unpause(self, r):
626626
assert r.client_unpause() == b"OK"
627627

628628
@pytest.mark.onlynoncluster
629-
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
630-
def test_client_no_evict(self, unstable_r):
631-
assert unstable_r.client_no_evict("ON") == "OK"
629+
@skip_if_server_version_lt("7.0.0")
630+
def test_client_no_evict(self, r):
631+
assert r.client_no_evict("ON") == "OK"
632632
with pytest.raises(TypeError):
633-
unstable_r.client_no_evict()
633+
r.client_no_evict()
634634

635635
@pytest.mark.onlynoncluster
636636
@skip_if_server_version_lt("3.2.0")
@@ -998,15 +998,15 @@ def test_unlink_with_multiple_keys(self, r):
998998
assert r.get("b") is None
999999

10001000
@pytest.mark.onlynoncluster
1001-
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
1002-
def test_lcs(self, unstable_r):
1003-
unstable_r.mset({"foo": "ohmytext", "bar": "mynewtext"})
1004-
assert unstable_r.lcs("foo", "bar") == "mytext"
1005-
assert unstable_r.lcs("foo", "bar", len=True) == 6
1001+
@skip_if_server_version_lt("7.0.0")
1002+
def test_lcs(self, r):
1003+
r.mset({"foo": "ohmytext", "bar": "mynewtext"})
1004+
assert r.lcs("foo", "bar") == "mytext"
1005+
assert r.lcs("foo", "bar", len=True) == 6
10061006
result = ["matches", [[[4, 7], [5, 8]]], "len", 6]
1007-
assert unstable_r.lcs("foo", "bar", idx=True, minmatchlen=3) == result
1007+
assert r.lcs("foo", "bar", idx=True, minmatchlen=3) == result
10081008
with pytest.raises(redis.ResponseError):
1009-
assert unstable_r.lcs("foo", "bar", len=True, idx=True)
1009+
assert r.lcs("foo", "bar", len=True, idx=True)
10101010

10111011
@skip_if_server_version_lt("2.6.0")
10121012
def test_dump_and_restore(self, r):
@@ -1671,27 +1671,27 @@ def test_brpoplpush_empty_string(self, r):
16711671
assert r.brpoplpush("a", "b") == b""
16721672

16731673
@pytest.mark.onlynoncluster
1674-
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
1675-
def test_blmpop(self, unstable_r):
1676-
unstable_r.rpush("a", "1", "2", "3", "4", "5")
1674+
@skip_if_server_version_lt("7.0.0")
1675+
def test_blmpop(self, r):
1676+
r.rpush("a", "1", "2", "3", "4", "5")
16771677
res = ["a", ["1", "2"]]
1678-
assert unstable_r.blmpop(1, "2", "b", "a", direction="LEFT", count=2) == res
1678+
assert r.blmpop(1, "2", "b", "a", direction="LEFT", count=2) == res
16791679
with pytest.raises(TypeError):
1680-
unstable_r.blmpop(1, "2", "b", "a", count=2)
1681-
unstable_r.rpush("b", "6", "7", "8", "9")
1682-
assert unstable_r.blmpop(0, "2", "b", "a", direction="LEFT") == ["b", ["6"]]
1683-
assert unstable_r.blmpop(1, "2", "foo", "bar", direction="RIGHT") is None
1680+
r.blmpop(1, "2", "b", "a", count=2)
1681+
r.rpush("b", "6", "7", "8", "9")
1682+
assert r.blmpop(0, "2", "b", "a", direction="LEFT") == ["b", ["6"]]
1683+
assert r.blmpop(1, "2", "foo", "bar", direction="RIGHT") is None
16841684

16851685
@pytest.mark.onlynoncluster
1686-
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
1687-
def test_lmpop(self, unstable_r):
1688-
unstable_r.rpush("foo", "1", "2", "3", "4", "5")
1686+
@skip_if_server_version_lt("7.0.0")
1687+
def test_lmpop(self, r):
1688+
r.rpush("foo", "1", "2", "3", "4", "5")
16891689
result = ["foo", ["1", "2"]]
1690-
assert unstable_r.lmpop("2", "bar", "foo", direction="LEFT", count=2) == result
1690+
assert r.lmpop("2", "bar", "foo", direction="LEFT", count=2) == result
16911691
with pytest.raises(redis.ResponseError):
1692-
unstable_r.lmpop("2", "bar", "foo", direction="up", count=2)
1693-
unstable_r.rpush("bar", "a", "b", "c", "d")
1694-
assert unstable_r.lmpop("2", "bar", "foo", direction="LEFT") == ["bar", ["a"]]
1692+
r.lmpop("2", "bar", "foo", direction="up", count=2)
1693+
r.rpush("bar", "a", "b", "c", "d")
1694+
assert r.lmpop("2", "bar", "foo", direction="LEFT") == ["bar", ["a"]]
16951695

16961696
def test_lindex(self, r):
16971697
r.rpush("a", "1", "2", "3")
@@ -1962,13 +1962,13 @@ def test_sinter(self, r):
19621962
assert r.sinter("a", "b") == {b"2", b"3"}
19631963

19641964
@pytest.mark.onlynoncluster
1965-
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
1966-
def test_sintercard(self, unstable_r):
1967-
unstable_r.sadd("a", 1, 2, 3)
1968-
unstable_r.sadd("b", 1, 2, 3)
1969-
unstable_r.sadd("c", 1, 3, 4)
1970-
assert unstable_r.sintercard(3, ["a", "b", "c"]) == 2
1971-
assert unstable_r.sintercard(3, ["a", "b", "c"], limit=1) == 1
1965+
@skip_if_server_version_lt("7.0.0")
1966+
def test_sintercard(self, r):
1967+
r.sadd("a", 1, 2, 3)
1968+
r.sadd("b", 1, 2, 3)
1969+
r.sadd("c", 1, 3, 4)
1970+
assert r.sintercard(3, ["a", "b", "c"]) == 2
1971+
assert r.sintercard(3, ["a", "b", "c"], limit=1) == 1
19721972

19731973
@pytest.mark.onlynoncluster
19741974
def test_sinterstore(self, r):
@@ -2202,13 +2202,13 @@ def test_zinter(self, r):
22022202
]
22032203

22042204
@pytest.mark.onlynoncluster
2205-
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
2206-
def test_zintercard(self, unstable_r):
2207-
unstable_r.zadd("a", {"a1": 1, "a2": 2, "a3": 1})
2208-
unstable_r.zadd("b", {"a1": 2, "a2": 2, "a3": 2})
2209-
unstable_r.zadd("c", {"a1": 6, "a3": 5, "a4": 4})
2210-
assert unstable_r.zintercard(3, ["a", "b", "c"]) == 2
2211-
assert unstable_r.zintercard(3, ["a", "b", "c"], limit=1) == 1
2205+
@skip_if_server_version_lt("7.0.0")
2206+
def test_zintercard(self, r):
2207+
r.zadd("a", {"a1": 1, "a2": 2, "a3": 1})
2208+
r.zadd("b", {"a1": 2, "a2": 2, "a3": 2})
2209+
r.zadd("c", {"a1": 6, "a3": 5, "a4": 4})
2210+
assert r.zintercard(3, ["a", "b", "c"]) == 2
2211+
assert r.zintercard(3, ["a", "b", "c"], limit=1) == 1
22122212

22132213
@pytest.mark.onlynoncluster
22142214
def test_zinterstore_sum(self, r):
@@ -2297,28 +2297,28 @@ def test_bzpopmin(self, r):
22972297
assert r.bzpopmin("c", timeout=1) == (b"c", b"c1", 100)
22982298

22992299
@pytest.mark.onlynoncluster
2300-
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
2301-
def test_zmpop(self, unstable_r):
2302-
unstable_r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
2300+
@skip_if_server_version_lt("7.0.0")
2301+
def test_zmpop(self, r):
2302+
r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
23032303
res = ["a", [["a1", "1"], ["a2", "2"]]]
2304-
assert unstable_r.zmpop("2", ["b", "a"], min=True, count=2) == res
2304+
assert r.zmpop("2", ["b", "a"], min=True, count=2) == res
23052305
with pytest.raises(redis.DataError):
2306-
unstable_r.zmpop("2", ["b", "a"], count=2)
2307-
unstable_r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
2308-
assert unstable_r.zmpop("2", ["b", "a"], max=True) == ["b", [["b1", "10"]]]
2306+
r.zmpop("2", ["b", "a"], count=2)
2307+
r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
2308+
assert r.zmpop("2", ["b", "a"], max=True) == ["b", [["b1", "10"]]]
23092309

23102310
@pytest.mark.onlynoncluster
2311-
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
2312-
def test_bzmpop(self, unstable_r):
2313-
unstable_r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
2311+
@skip_if_server_version_lt("7.0.0")
2312+
def test_bzmpop(self, r):
2313+
r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
23142314
res = ["a", [["a1", "1"], ["a2", "2"]]]
2315-
assert unstable_r.bzmpop(1, "2", ["b", "a"], min=True, count=2) == res
2315+
assert r.bzmpop(1, "2", ["b", "a"], min=True, count=2) == res
23162316
with pytest.raises(redis.DataError):
2317-
unstable_r.bzmpop(1, "2", ["b", "a"], count=2)
2318-
unstable_r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
2317+
r.bzmpop(1, "2", ["b", "a"], count=2)
2318+
r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
23192319
res = ["b", [["b1", "10"]]]
2320-
assert unstable_r.bzmpop(0, "2", ["b", "a"], max=True) == res
2321-
assert unstable_r.bzmpop(1, "2", ["foo", "bar"], max=True) is None
2320+
assert r.bzmpop(0, "2", ["b", "a"], max=True) == res
2321+
assert r.bzmpop(1, "2", ["foo", "bar"], max=True) is None
23222322

23232323
def test_zrange(self, r):
23242324
r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
@@ -4481,12 +4481,14 @@ def test_replicaof(self, r):
44814481
assert r.replicaof("NO ONE")
44824482
assert r.replicaof("NO", "ONE")
44834483

4484+
@pytest.mark.replica
44844485
@skip_if_server_version_lt("2.8.0")
44854486
def test_sync(self, r):
44864487
r2 = redis.Redis(port=6380, decode_responses=False)
44874488
res = r2.sync()
44884489
assert b"REDIS" in res
44894490

4491+
@pytest.mark.replica
44904492
@skip_if_server_version_lt("2.8.0")
44914493
def test_psync(self, r):
44924494
r2 = redis.Redis(port=6380, decode_responses=False)

tests/test_scripting.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ def test_eval_multiply(self, r):
6565
# 2 * 3 == 6
6666
assert r.eval(multiply_script, 1, "a", 3) == 6
6767

68-
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
68+
@skip_if_server_version_lt("7.0.0")
6969
@pytest.mark.onlynoncluster
70-
def test_eval_ro(self, unstable_r):
71-
unstable_r.set("a", "b")
72-
assert unstable_r.eval_ro("return redis.call('GET', KEYS[1])", 1, "a") == "b"
70+
def test_eval_ro(self, r):
71+
r.set("a", "b")
72+
assert r.eval_ro("return redis.call('GET', KEYS[1])", 1, "a") == "b"
7373
with pytest.raises(redis.ResponseError):
74-
unstable_r.eval_ro("return redis.call('DEL', KEYS[1])", 1, "a")
74+
r.eval_ro("return redis.call('DEL', KEYS[1])", 1, "a")
7575

7676
def test_eval_msgpack(self, r):
7777
msgpack_message_dumped = b"\x81\xa4name\xa3Joe"
@@ -154,15 +154,15 @@ def test_evalsha(self, r):
154154
# 2 * 3 == 6
155155
assert r.evalsha(sha, 1, "a", 3) == 6
156156

157-
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
157+
@skip_if_server_version_lt("7.0.0")
158158
@pytest.mark.onlynoncluster
159-
def test_evalsha_ro(self, unstable_r):
160-
unstable_r.set("a", "b")
161-
get_sha = unstable_r.script_load("return redis.call('GET', KEYS[1])")
162-
del_sha = unstable_r.script_load("return redis.call('DEL', KEYS[1])")
163-
assert unstable_r.evalsha_ro(get_sha, 1, "a") == "b"
159+
def test_evalsha_ro(self, r):
160+
r.set("a", "b")
161+
get_sha = r.script_load("return redis.call('GET', KEYS[1])")
162+
del_sha = r.script_load("return redis.call('DEL', KEYS[1])")
163+
assert r.evalsha_ro(get_sha, 1, "a") == "b"
164164
with pytest.raises(redis.ResponseError):
165-
unstable_r.evalsha_ro(del_sha, 1, "a")
165+
r.evalsha_ro(del_sha, 1, "a")
166166

167167
def test_evalsha_script_not_loaded(self, r):
168168
r.set("a", 2)

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ markers =
66
onlycluster: marks tests to be run only with cluster mode redis
77
onlynoncluster: marks tests to be run only with standalone redis
88
ssl: marker for only the ssl tests
9+
replica: replica tests
10+
experimental: run only experimental tests
911

1012
[tox]
1113
minversion = 3.2.0

0 commit comments

Comments
 (0)