summaryrefslogtreecommitdiff
path: root/tests/test_commands.py
diff options
context:
space:
mode:
authorBar Shaul <88437685+barshaul@users.noreply.github.com>2021-11-25 14:15:24 +0200
committerGitHub <noreply@github.com>2021-11-25 14:15:24 +0200
commit9db1eec71b443b8e7e74ff503bae651dc6edf411 (patch)
treece23ac6f923df54676349603f4e5551dfc801057 /tests/test_commands.py
parent021d4ac0edaecedb9b83235700cc4699cb119ef1 (diff)
downloadredis-py-9db1eec71b443b8e7e74ff503bae651dc6edf411.tar.gz
Adding RedisCluster client to support Redis Cluster Mode (#1660)
Co-authored-by: Chayim <chayim@users.noreply.github.com> Co-authored-by: Anas <anas.el.amraoui@live.com>
Diffstat (limited to 'tests/test_commands.py')
-rw-r--r--tests/test_commands.py138
1 files changed, 133 insertions, 5 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py
index dbd0442..780a1bf 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -47,6 +47,7 @@ def get_stream_message(client, stream, message_id):
# RESPONSE CALLBACKS
+@pytest.mark.onlynoncluster
class TestResponseCallbacks:
"Tests for the response callback system"
@@ -68,18 +69,21 @@ class TestRedisCommands:
r['a']
# SERVER INFORMATION
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
def test_acl_cat_no_category(self, r):
categories = r.acl_cat()
assert isinstance(categories, list)
assert 'read' in categories
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
def test_acl_cat_with_category(self, r):
commands = r.acl_cat('read')
assert isinstance(commands, list)
assert 'get' in commands
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_deluser(self, r, request):
@@ -105,6 +109,7 @@ class TestRedisCommands:
assert r.acl_getuser(users[3]) is None
assert r.acl_getuser(users[4]) is None
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_genpass(self, r):
@@ -119,6 +124,7 @@ class TestRedisCommands:
r.acl_genpass(555)
assert isinstance(password, str)
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_getuser_setuser(self, r, request):
@@ -207,12 +213,14 @@ class TestRedisCommands:
hashed_passwords=['-' + hashed_password])
assert len(r.acl_getuser(username)['passwords']) == 1
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
def test_acl_help(self, r):
res = r.acl_help()
assert isinstance(res, list)
assert len(res) != 0
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_list(self, r, request):
@@ -226,6 +234,7 @@ class TestRedisCommands:
users = r.acl_list()
assert len(users) == 2
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_log(self, r, request):
@@ -262,6 +271,7 @@ class TestRedisCommands:
assert 'client-info' in r.acl_log(count=1)[0]
assert r.acl_log_reset()
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_setuser_categories_without_prefix_fails(self, r, request):
@@ -274,6 +284,7 @@ class TestRedisCommands:
with pytest.raises(exceptions.DataError):
r.acl_setuser(username, categories=['list'])
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_setuser_commands_without_prefix_fails(self, r, request):
@@ -286,6 +297,7 @@ class TestRedisCommands:
with pytest.raises(exceptions.DataError):
r.acl_setuser(username, commands=['get'])
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_setuser_add_passwords_and_nopass_fails(self, r, request):
@@ -298,28 +310,33 @@ class TestRedisCommands:
with pytest.raises(exceptions.DataError):
r.acl_setuser(username, passwords='+mypass', nopass=True)
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
def test_acl_users(self, r):
users = r.acl_users()
assert isinstance(users, list)
assert len(users) > 0
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
def test_acl_whoami(self, r):
username = r.acl_whoami()
assert isinstance(username, str)
+ @pytest.mark.onlynoncluster
def test_client_list(self, r):
clients = r.client_list()
assert isinstance(clients[0], dict)
assert 'addr' in clients[0]
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_client_info(self, r):
info = r.client_info()
assert isinstance(info, dict)
assert 'addr' in info
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('5.0.0')
def test_client_list_types_not_replica(self, r):
with pytest.raises(exceptions.RedisError):
@@ -333,6 +350,7 @@ class TestRedisCommands:
clients = r.client_list(_type='replica')
assert isinstance(clients, list)
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_client_list_client_id(self, r, request):
clients = r.client_list()
@@ -347,16 +365,19 @@ class TestRedisCommands:
clients_listed = r.client_list(client_id=clients[:-1])
assert len(clients_listed) > 1
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('5.0.0')
def test_client_id(self, r):
assert r.client_id() > 0
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_client_trackinginfo(self, r):
res = r.client_trackinginfo()
assert len(res) > 2
assert 'prefixes' in res
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('5.0.0')
def test_client_unblock(self, r):
myid = r.client_id()
@@ -364,15 +385,18 @@ class TestRedisCommands:
assert not r.client_unblock(myid, error=True)
assert not r.client_unblock(myid, error=False)
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.6.9')
def test_client_getname(self, r):
assert r.client_getname() is None
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.6.9')
def test_client_setname(self, r):
assert r.client_setname('redis_py_test')
assert r.client_getname() == 'redis_py_test'
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.6.9')
def test_client_kill(self, r, r2):
r.client_setname('redis-py-c1')
@@ -406,6 +430,7 @@ class TestRedisCommands:
with pytest.raises(exceptions.DataError):
r.client_kill_filter(_type="caster")
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.8.12')
def test_client_kill_filter_by_id(self, r, r2):
r.client_setname('redis-py-c1')
@@ -426,6 +451,7 @@ class TestRedisCommands:
assert len(clients) == 1
assert clients[0].get('name') == 'redis-py-c1'
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.8.12')
def test_client_kill_filter_by_addr(self, r, r2):
r.client_setname('redis-py-c1')
@@ -481,6 +507,7 @@ class TestRedisCommands:
assert c['user'] != killuser
r.acl_deluser(killuser)
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.9.50')
@skip_if_redis_enterprise
def test_client_pause(self, r):
@@ -489,11 +516,13 @@ class TestRedisCommands:
with pytest.raises(exceptions.RedisError):
r.client_pause(timeout='not an integer')
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
@skip_if_redis_enterprise
def test_client_unpause(self, r):
assert r.client_unpause() == b'OK'
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('3.2.0')
def test_client_reply(self, r, r_timeout):
assert r_timeout.client_reply('ON') == b'OK'
@@ -507,6 +536,7 @@ class TestRedisCommands:
# validate it was set
assert r.get('foo') == b'bar'
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.0.0')
@skip_if_redis_enterprise
def test_client_getredir(self, r):
@@ -519,6 +549,7 @@ class TestRedisCommands:
# # assert 'maxmemory' in data
# assert data['maxmemory'].isdigit()
+ @pytest.mark.onlynoncluster
@skip_if_redis_enterprise
def test_config_resetstat(self, r):
r.ping()
@@ -535,14 +566,17 @@ class TestRedisCommands:
assert r.config_set('timeout', 0)
assert r.config_get()['timeout'] == '0'
+ @pytest.mark.onlynoncluster
def test_dbsize(self, r):
r['a'] = 'foo'
r['b'] = 'bar'
assert r.dbsize() == 2
+ @pytest.mark.onlynoncluster
def test_echo(self, r):
assert r.echo('foo bar') == b'foo bar'
+ @pytest.mark.onlynoncluster
def test_info(self, r):
r['a'] = 'foo'
r['b'] = 'bar'
@@ -551,10 +585,12 @@ class TestRedisCommands:
assert 'arch_bits' in info.keys()
assert 'redis_version' in info.keys()
+ @pytest.mark.onlynoncluster
@skip_if_redis_enterprise
def test_lastsave(self, r):
assert isinstance(r.lastsave(), datetime.datetime)
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('5.0.0')
def test_lolwut(self, r):
lolwut = r.lolwut().decode('utf-8')
@@ -573,9 +609,11 @@ class TestRedisCommands:
def test_ping(self, r):
assert r.ping()
+ @pytest.mark.onlynoncluster
def test_quit(self, r):
assert r.quit()
+ @pytest.mark.onlynoncluster
def test_slowlog_get(self, r, slowlog):
assert r.slowlog_reset()
unicode_string = chr(3456) + 'abcd' + chr(3421)
@@ -613,6 +651,7 @@ class TestRedisCommands:
# Complexity info stored as fourth item in list
response.insert(3, COMPLEXITY_STATEMENT)
return r.response_callbacks[command_name](responses, **options)
+
r.parse_response = parse_response
# test
@@ -626,6 +665,7 @@ class TestRedisCommands:
# tear down monkeypatch
r.parse_response = old_parse_response
+ @pytest.mark.onlynoncluster
def test_slowlog_get_limit(self, r, slowlog):
assert r.slowlog_reset()
r.get('foo')
@@ -634,6 +674,7 @@ class TestRedisCommands:
# only one command, based on the number we passed to slowlog_get()
assert len(slowlog) == 1
+ @pytest.mark.onlynoncluster
def test_slowlog_length(self, r, slowlog):
r.get('foo')
assert isinstance(r.slowlog_len(), int)
@@ -677,12 +718,14 @@ class TestRedisCommands:
assert r.bitcount('a', -2, -1) == 2
assert r.bitcount('a', 1, 1) == 1
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.6.0')
def test_bitop_not_empty_string(self, r):
r['a'] = ''
r.bitop('not', 'r', 'a')
assert r.get('r') is None
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.6.0')
def test_bitop_not(self, r):
test_str = b'\xAA\x00\xFF\x55'
@@ -691,6 +734,7 @@ class TestRedisCommands:
r.bitop('not', 'r', 'a')
assert int(binascii.hexlify(r['r']), 16) == correct
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.6.0')
def test_bitop_not_in_place(self, r):
test_str = b'\xAA\x00\xFF\x55'
@@ -699,6 +743,7 @@ class TestRedisCommands:
r.bitop('not', 'a', 'a')
assert int(binascii.hexlify(r['a']), 16) == correct
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.6.0')
def test_bitop_single_string(self, r):
test_str = b'\x01\x02\xFF'
@@ -710,6 +755,7 @@ class TestRedisCommands:
assert r['res2'] == test_str
assert r['res3'] == test_str
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.6.0')
def test_bitop_string_operands(self, r):
r['a'] = b'\x01\x02\xFF\xFF'
@@ -721,6 +767,7 @@ class TestRedisCommands:
assert int(binascii.hexlify(r['res2']), 16) == 0x0102FFFF
assert int(binascii.hexlify(r['res3']), 16) == 0x000000FF
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.8.7')
def test_bitpos(self, r):
key = 'key:bitpos'
@@ -743,6 +790,7 @@ class TestRedisCommands:
with pytest.raises(exceptions.RedisError):
r.bitpos(key, 7) == 12
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_copy(self, r):
assert r.copy("a", "b") == 0
@@ -751,6 +799,7 @@ class TestRedisCommands:
assert r.get("a") == b"foo"
assert r.get("b") == b"foo"
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_copy_and_replace(self, r):
r.set("a", "foo1")
@@ -758,6 +807,7 @@ class TestRedisCommands:
assert r.copy("a", "b") == 0
assert r.copy("a", "b", replace=True) == 1
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_copy_to_another_database(self, request):
r0 = _get_client(redis.Redis, request, db=0)
@@ -973,6 +1023,7 @@ class TestRedisCommands:
assert r.incrbyfloat('a', 1.1) == 2.1
assert float(r['a']) == float(2.1)
+ @pytest.mark.onlynoncluster
def test_keys(self, r):
assert r.keys() == []
keys_with_underscores = {b'test_a', b'test_b'}
@@ -982,6 +1033,7 @@ class TestRedisCommands:
assert set(r.keys(pattern='test_*')) == keys_with_underscores
assert set(r.keys(pattern='test*')) == keys
+ @pytest.mark.onlynoncluster
def test_mget(self, r):
assert r.mget([]) == []
assert r.mget(['a', 'b']) == [None, None]
@@ -990,24 +1042,28 @@ class TestRedisCommands:
r['c'] = '3'
assert r.mget('a', 'other', 'b', 'c') == [b'1', None, b'2', b'3']
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_lmove(self, r):
r.rpush('a', 'one', 'two', 'three', 'four')
assert r.lmove('a', 'b')
assert r.lmove('a', 'b', 'right', 'left')
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_blmove(self, r):
r.rpush('a', 'one', 'two', 'three', 'four')
assert r.blmove('a', 'b', 5)
assert r.blmove('a', 'b', 1, 'RIGHT', 'LEFT')
+ @pytest.mark.onlynoncluster
def test_mset(self, r):
d = {'a': b'1', 'b': b'2', 'c': b'3'}
assert r.mset(d)
for k, v in d.items():
assert r[k] == v
+ @pytest.mark.onlynoncluster
def test_msetnx(self, r):
d = {'a': b'1', 'b': b'2', 'c': b'3'}
assert r.msetnx(d)
@@ -1086,18 +1142,21 @@ class TestRedisCommands:
# with duplications
assert len(r.hrandfield('key', -10)) == 10
+ @pytest.mark.onlynoncluster
def test_randomkey(self, r):
assert r.randomkey() is None
for key in ('a', 'b', 'c'):
r[key] = 1
assert r.randomkey() in (b'a', b'b', b'c')
+ @pytest.mark.onlynoncluster
def test_rename(self, r):
r['a'] = '1'
assert r.rename('a', 'b')
assert r.get('a') is None
assert r['b'] == b'1'
+ @pytest.mark.onlynoncluster
def test_renamenx(self, r):
r['a'] = '1'
r['b'] = '2'
@@ -1203,8 +1262,8 @@ class TestRedisCommands:
@skip_if_server_version_lt('6.0.0')
def test_stralgo_lcs(self, r):
- key1 = 'key1'
- key2 = 'key2'
+ key1 = '{foo}key1'
+ key2 = '{foo}key2'
value1 = 'ohmytext'
value2 = 'mynewtext'
res = 'mytext'
@@ -1294,6 +1353,7 @@ class TestRedisCommands:
assert r.type('a') == b'zset'
# LIST COMMANDS
+ @pytest.mark.onlynoncluster
def test_blpop(self, r):
r.rpush('a', '1', '2')
r.rpush('b', '3', '4')
@@ -1305,6 +1365,7 @@ class TestRedisCommands:
r.rpush('c', '1')
assert r.blpop('c', timeout=1) == (b'c', b'1')
+ @pytest.mark.onlynoncluster
def test_brpop(self, r):
r.rpush('a', '1', '2')
r.rpush('b', '3', '4')
@@ -1316,6 +1377,7 @@ class TestRedisCommands:
r.rpush('c', '1')
assert r.brpop('c', timeout=1) == (b'c', b'1')
+ @pytest.mark.onlynoncluster
def test_brpoplpush(self, r):
r.rpush('a', '1', '2')
r.rpush('b', '3', '4')
@@ -1325,6 +1387,7 @@ class TestRedisCommands:
assert r.lrange('a', 0, -1) == []
assert r.lrange('b', 0, -1) == [b'1', b'2', b'3', b'4']
+ @pytest.mark.onlynoncluster
def test_brpoplpush_empty_string(self, r):
r.rpush('a', '')
assert r.brpoplpush('a', 'b') == b''
@@ -1428,6 +1491,7 @@ class TestRedisCommands:
assert r.rpop('a') is None
assert r.rpop('a', 3) is None
+ @pytest.mark.onlynoncluster
def test_rpoplpush(self, r):
r.rpush('a', 'a1', 'a2', 'a3')
r.rpush('b', 'b1', 'b2', 'b3')
@@ -1481,6 +1545,7 @@ class TestRedisCommands:
assert r.lrange('a', 0, -1) == [b'1', b'2', b'3', b'4']
# SCAN COMMANDS
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.8.0')
def test_scan(self, r):
r.set('a', 1)
@@ -1492,6 +1557,7 @@ class TestRedisCommands:
_, keys = r.scan(match='a')
assert set(keys) == {b'a'}
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt("6.0.0")
def test_scan_type(self, r):
r.sadd('a-set', 1)
@@ -1500,6 +1566,7 @@ class TestRedisCommands:
_, keys = r.scan(match='a*', _type='SET')
assert set(keys) == {b'a-set'}
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.8.0')
def test_scan_iter(self, r):
r.set('a', 1)
@@ -1571,12 +1638,14 @@ class TestRedisCommands:
r.sadd('a', '1', '2', '3')
assert r.scard('a') == 3
+ @pytest.mark.onlynoncluster
def test_sdiff(self, r):
r.sadd('a', '1', '2', '3')
assert r.sdiff('a', 'b') == {b'1', b'2', b'3'}
r.sadd('b', '2', '3')
assert r.sdiff('a', 'b') == {b'1'}
+ @pytest.mark.onlynoncluster
def test_sdiffstore(self, r):
r.sadd('a', '1', '2', '3')
assert r.sdiffstore('c', 'a', 'b') == 3
@@ -1585,12 +1654,14 @@ class TestRedisCommands:
assert r.sdiffstore('c', 'a', 'b') == 1
assert r.smembers('c') == {b'1'}
+ @pytest.mark.onlynoncluster
def test_sinter(self, r):
r.sadd('a', '1', '2', '3')
assert r.sinter('a', 'b') == set()
r.sadd('b', '2', '3')
assert r.sinter('a', 'b') == {b'2', b'3'}
+ @pytest.mark.onlynoncluster
def test_sinterstore(self, r):
r.sadd('a', '1', '2', '3')
assert r.sinterstore('c', 'a', 'b') == 0
@@ -1617,6 +1688,7 @@ class TestRedisCommands:
assert r.smismember('a', '1', '4', '2', '3') == result_list
assert r.smismember('a', ['1', '4', '2', '3']) == result_list
+ @pytest.mark.onlynoncluster
def test_smove(self, r):
r.sadd('a', 'a1', 'a2')
r.sadd('b', 'b1', 'b2')
@@ -1662,11 +1734,13 @@ class TestRedisCommands:
assert r.srem('a', '2', '4') == 2
assert r.smembers('a') == {b'1', b'3'}
+ @pytest.mark.onlynoncluster
def test_sunion(self, r):
r.sadd('a', '1', '2')
r.sadd('b', '2', '3')
assert r.sunion('a', 'b') == {b'1', b'2', b'3'}
+ @pytest.mark.onlynoncluster
def test_sunionstore(self, r):
r.sadd('a', '1', '2')
r.sadd('b', '2', '3')
@@ -1678,6 +1752,7 @@ class TestRedisCommands:
with pytest.raises(NotImplementedError):
r.debug_segfault()
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('3.2.0')
def test_script_debug(self, r):
with pytest.raises(NotImplementedError):
@@ -1759,6 +1834,7 @@ class TestRedisCommands:
assert r.zcount('a', 1, '(' + str(2)) == 1
assert r.zcount('a', 10, 20) == 0
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_zdiff(self, r):
r.zadd('a', {'a1': 1, 'a2': 2, 'a3': 3})
@@ -1766,6 +1842,7 @@ class TestRedisCommands:
assert r.zdiff(['a', 'b']) == [b'a3']
assert r.zdiff(['a', 'b'], withscores=True) == [b'a3', b'3']
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_zdiffstore(self, r):
r.zadd('a', {'a1': 1, 'a2': 2, 'a3': 3})
@@ -1787,6 +1864,7 @@ class TestRedisCommands:
assert r.zlexcount('a', '-', '+') == 7
assert r.zlexcount('a', '[b', '[f') == 5
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_zinter(self, r):
r.zadd('a', {'a1': 1, 'a2': 2, 'a3': 1})
@@ -1809,6 +1887,7 @@ class TestRedisCommands:
assert r.zinter({'a': 1, 'b': 2, 'c': 3}, withscores=True) \
== [(b'a3', 20), (b'a1', 23)]
+ @pytest.mark.onlynoncluster
def test_zinterstore_sum(self, r):
r.zadd('a', {'a1': 1, 'a2': 1, 'a3': 1})
r.zadd('b', {'a1': 2, 'a2': 2, 'a3': 2})
@@ -1817,6 +1896,7 @@ class TestRedisCommands:
assert r.zrange('d', 0, -1, withscores=True) == \
[(b'a3', 8), (b'a1', 9)]
+ @pytest.mark.onlynoncluster
def test_zinterstore_max(self, r):
r.zadd('a', {'a1': 1, 'a2': 1, 'a3': 1})
r.zadd('b', {'a1': 2, 'a2': 2, 'a3': 2})
@@ -1825,6 +1905,7 @@ class TestRedisCommands:
assert r.zrange('d', 0, -1, withscores=True) == \
[(b'a3', 5), (b'a1', 6)]
+ @pytest.mark.onlynoncluster
def test_zinterstore_min(self, r):
r.zadd('a', {'a1': 1, 'a2': 2, 'a3': 3})
r.zadd('b', {'a1': 2, 'a2': 3, 'a3': 5})
@@ -1833,6 +1914,7 @@ class TestRedisCommands:
assert r.zrange('d', 0, -1, withscores=True) == \
[(b'a1', 1), (b'a3', 3)]
+ @pytest.mark.onlynoncluster
def test_zinterstore_with_weight(self, r):
r.zadd('a', {'a1': 1, 'a2': 1, 'a3': 1})
r.zadd('b', {'a1': 2, 'a2': 2, 'a3': 2})
@@ -1871,6 +1953,7 @@ class TestRedisCommands:
# with duplications
assert len(r.zrandmember('a', -10)) == 10
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('4.9.0')
def test_bzpopmax(self, r):
r.zadd('a', {'a1': 1, 'a2': 2})
@@ -1883,6 +1966,7 @@ class TestRedisCommands:
r.zadd('c', {'c1': 100})
assert r.bzpopmax('c', timeout=1) == (b'c', b'c1', 100)
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('4.9.0')
def test_bzpopmin(self, r):
r.zadd('a', {'a1': 1, 'a2': 2})
@@ -1952,6 +2036,7 @@ class TestRedisCommands:
# rev
assert r.zrange('a', 0, 1, desc=True) == [b'a5', b'a4']
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_zrangestore(self, r):
r.zadd('a', {'a1': 1, 'a2': 2, 'a3': 3})
@@ -2089,6 +2174,7 @@ class TestRedisCommands:
assert r.zscore('a', 'a2') == 2.0
assert r.zscore('a', 'a4') is None
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_zunion(self, r):
r.zadd('a', {'a1': 1, 'a2': 1, 'a3': 1})
@@ -2109,6 +2195,7 @@ class TestRedisCommands:
assert r.zunion({'a': 1, 'b': 2, 'c': 3}, withscores=True)\
== [(b'a2', 5), (b'a4', 12), (b'a3', 20), (b'a1', 23)]
+ @pytest.mark.onlynoncluster
def test_zunionstore_sum(self, r):
r.zadd('a', {'a1': 1, 'a2': 1, 'a3': 1})
r.zadd('b', {'a1': 2, 'a2': 2, 'a3': 2})
@@ -2117,6 +2204,7 @@ class TestRedisCommands:
assert r.zrange('d', 0, -1, withscores=True) == \
[(b'a2', 3), (b'a4', 4), (b'a3', 8), (b'a1', 9)]
+ @pytest.mark.onlynoncluster
def test_zunionstore_max(self, r):
r.zadd('a', {'a1': 1, 'a2': 1, 'a3': 1})
r.zadd('b', {'a1': 2, 'a2': 2, 'a3': 2})
@@ -2125,6 +2213,7 @@ class TestRedisCommands:
assert r.zrange('d', 0, -1, withscores=True) == \
[(b'a2', 2), (b'a4', 4), (b'a3', 5), (b'a1', 6)]
+ @pytest.mark.onlynoncluster
def test_zunionstore_min(self, r):
r.zadd('a', {'a1': 1, 'a2': 2, 'a3': 3})
r.zadd('b', {'a1': 2, 'a2': 2, 'a3': 4})
@@ -2133,6 +2222,7 @@ class TestRedisCommands:
assert r.zrange('d', 0, -1, withscores=True) == \
[(b'a1', 1), (b'a2', 2), (b'a3', 3), (b'a4', 4)]
+ @pytest.mark.onlynoncluster
def test_zunionstore_with_weight(self, r):
r.zadd('a', {'a1': 1, 'a2': 1, 'a3': 1})
r.zadd('b', {'a1': 2, 'a2': 2, 'a3': 2})
@@ -2160,6 +2250,7 @@ class TestRedisCommands:
assert r.pfadd('a', *members) == 0
assert r.pfcount('a') == len(members)
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.8.9')
def test_pfcount(self, r):
members = {b'1', b'2', b'3'}
@@ -2170,6 +2261,7 @@ class TestRedisCommands:
assert r.pfcount('b') == len(members_b)
assert r.pfcount('a', 'b') == len(members_b.union(members))
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('2.8.9')
def test_pfmerge(self, r):
mema = {b'1', b'2', b'3'}
@@ -2264,8 +2356,9 @@ class TestRedisCommands:
assert r.hmget('a', 'a', 'b', 'c') == [b'1', b'2', b'3']
def test_hmset(self, r):
- warning_message = (r'^Redis\.hmset\(\) is deprecated\. '
- r'Use Redis\.hset\(\) instead\.$')
+ redis_class = type(r).__name__
+ warning_message = (r'^{0}\.hmset\(\) is deprecated\. '
+ r'Use {0}\.hset\(\) instead\.$'.format(redis_class))
h = {b'a': b'1', b'b': b'2', b'c': b'3'}
with pytest.warns(DeprecationWarning, match=warning_message):
assert r.hmset('a', h)
@@ -2300,6 +2393,7 @@ class TestRedisCommands:
r.rpush('a', '3', '2', '1', '4')
assert r.sort('a', start=1, num=2) == [b'2', b'3']
+ @pytest.mark.onlynoncluster
def test_sort_by(self, r):
r['score:1'] = 8
r['score:2'] = 3
@@ -2307,6 +2401,7 @@ class TestRedisCommands:
r.rpush('a', '3', '2', '1')
assert r.sort('a', by='score:*') == [b'2', b'3', b'1']
+ @pytest.mark.onlynoncluster
def test_sort_get(self, r):
r['user:1'] = 'u1'
r['user:2'] = 'u2'
@@ -2314,6 +2409,7 @@ class TestRedisCommands:
r.rpush('a', '2', '3', '1')
assert r.sort('a', get='user:*') == [b'u1', b'u2', b'u3']
+ @pytest.mark.onlynoncluster
def test_sort_get_multi(self, r):
r['user:1'] = 'u1'
r['user:2'] = 'u2'
@@ -2322,6 +2418,7 @@ class TestRedisCommands:
assert r.sort('a', get=('user:*', '#')) == \
[b'u1', b'1', b'u2', b'2', b'u3', b'3']
+ @pytest.mark.onlynoncluster
def test_sort_get_groups_two(self, r):
r['user:1'] = 'u1'
r['user:2'] = 'u2'
@@ -2330,6 +2427,7 @@ class TestRedisCommands:
assert r.sort('a', get=('user:*', '#'), groups=True) == \
[(b'u1', b'1'), (b'u2', b'2'), (b'u3', b'3')]
+ @pytest.mark.onlynoncluster
def test_sort_groups_string_get(self, r):
r['user:1'] = 'u1'
r['user:2'] = 'u2'
@@ -2338,6 +2436,7 @@ class TestRedisCommands:
with pytest.raises(exceptions.DataError):
r.sort('a', get='user:*', groups=True)
+ @pytest.mark.onlynoncluster
def test_sort_groups_just_one_get(self, r):
r['user:1'] = 'u1'
r['user:2'] = 'u2'
@@ -2354,6 +2453,7 @@ class TestRedisCommands:
with pytest.raises(exceptions.DataError):
r.sort('a', groups=True)
+ @pytest.mark.onlynoncluster
def test_sort_groups_three_gets(self, r):
r['user:1'] = 'u1'
r['user:2'] = 'u2'
@@ -2378,11 +2478,13 @@ class TestRedisCommands:
assert r.sort('a', alpha=True) == \
[b'a', b'b', b'c', b'd', b'e']
+ @pytest.mark.onlynoncluster
def test_sort_store(self, r):
r.rpush('a', '2', '3', '1')
assert r.sort('a', store='sorted_values') == 3
assert r.lrange('sorted_values', 0, -1) == [b'1', b'2', b'3']
+ @pytest.mark.onlynoncluster
def test_sort_all_options(self, r):
r['user:1:username'] = 'zeus'
r['user:2:username'] = 'titan'
@@ -2415,66 +2517,84 @@ class TestRedisCommands:
r.execute_command('SADD', 'issue#924', 1)
r.execute_command('SORT', 'issue#924')
+ @pytest.mark.onlynoncluster
def test_cluster_addslots(self, mock_cluster_resp_ok):
assert mock_cluster_resp_ok.cluster('ADDSLOTS', 1) is True
+ @pytest.mark.onlynoncluster
def test_cluster_count_failure_reports(self, mock_cluster_resp_int):
assert isinstance(mock_cluster_resp_int.cluster(
'COUNT-FAILURE-REPORTS', 'node'), int)
+ @pytest.mark.onlynoncluster
def test_cluster_countkeysinslot(self, mock_cluster_resp_int):
assert isinstance(mock_cluster_resp_int.cluster(
'COUNTKEYSINSLOT', 2), int)
+ @pytest.mark.onlynoncluster
def test_cluster_delslots(self, mock_cluster_resp_ok):
assert mock_cluster_resp_ok.cluster('DELSLOTS', 1) is True
+ @pytest.mark.onlynoncluster
def test_cluster_failover(self, mock_cluster_resp_ok):
assert mock_cluster_resp_ok.cluster('FAILOVER', 1) is True
+ @pytest.mark.onlynoncluster
def test_cluster_forget(self, mock_cluster_resp_ok):
assert mock_cluster_resp_ok.cluster('FORGET', 1) is True
+ @pytest.mark.onlynoncluster
def test_cluster_info(self, mock_cluster_resp_info):
assert isinstance(mock_cluster_resp_info.cluster('info'), dict)
+ @pytest.mark.onlynoncluster
def test_cluster_keyslot(self, mock_cluster_resp_int):
assert isinstance(mock_cluster_resp_int.cluster(
'keyslot', 'asdf'), int)
+ @pytest.mark.onlynoncluster
def test_cluster_meet(self, mock_cluster_resp_ok):
assert mock_cluster_resp_ok.cluster('meet', 'ip', 'port', 1) is True
+ @pytest.mark.onlynoncluster
def test_cluster_nodes(self, mock_cluster_resp_nodes):
assert isinstance(mock_cluster_resp_nodes.cluster('nodes'), dict)
+ @pytest.mark.onlynoncluster
def test_cluster_replicate(self, mock_cluster_resp_ok):
assert mock_cluster_resp_ok.cluster('replicate', 'nodeid') is True
+ @pytest.mark.onlynoncluster
def test_cluster_reset(self, mock_cluster_resp_ok):
assert mock_cluster_resp_ok.cluster('reset', 'hard') is True
+ @pytest.mark.onlynoncluster
def test_cluster_saveconfig(self, mock_cluster_resp_ok):
assert mock_cluster_resp_ok.cluster('saveconfig') is True
+ @pytest.mark.onlynoncluster
def test_cluster_setslot(self, mock_cluster_resp_ok):
assert mock_cluster_resp_ok.cluster('setslot', 1,
'IMPORTING', 'nodeid') is True
+ @pytest.mark.onlynoncluster
def test_cluster_slaves(self, mock_cluster_resp_slaves):
assert isinstance(mock_cluster_resp_slaves.cluster(
'slaves', 'nodeid'), dict)
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('3.0.0')
@skip_if_redis_enterprise
def test_readwrite(self, r):
assert r.readwrite()
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('3.0.0')
def test_readonly_invalid_cluster_state(self, r):
with pytest.raises(exceptions.RedisError):
r.readonly()
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('3.0.0')
def test_readonly(self, mock_cluster_resp_ok):
assert mock_cluster_resp_ok.readonly() is True
@@ -2701,6 +2821,7 @@ class TestRedisCommands:
with pytest.raises(exceptions.DataError):
assert r.geosearch('barcelona', member='place3', radius=100, any=1)
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('6.2.0')
def test_geosearchstore(self, r):
values = (2.1909389952632, 41.433791470673, 'place1') + \
@@ -2711,6 +2832,7 @@ class TestRedisCommands:
longitude=2.191, latitude=41.433, radius=1000)
assert r.zrange('places_barcelona', 0, -1) == [b'place1']
+ @pytest.mark.onlynoncluster
@skip_unless_arch_bits(64)
@skip_if_server_version_lt('6.2.0')
def test_geosearchstore_dist(self, r):
@@ -2802,6 +2924,7 @@ class TestRedisCommands:
assert r.georadius('barcelona', 2.191, 41.433, 3000, sort='DESC') == \
[b'place2', b'place1']
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('3.2.0')
def test_georadius_store(self, r):
values = (2.1909389952632, 41.433791470673, 'place1') + \
@@ -2811,6 +2934,7 @@ class TestRedisCommands:
r.georadius('barcelona', 2.191, 41.433, 1000, store='places_barcelona')
assert r.zrange('places_barcelona', 0, -1) == [b'place1']
+ @pytest.mark.onlynoncluster
@skip_unless_arch_bits(64)
@skip_if_server_version_lt('3.2.0')
def test_georadius_store_dist(self, r):
@@ -3658,6 +3782,7 @@ class TestRedisCommands:
r.set('foo', 'bar')
assert isinstance(r.memory_usage('foo'), int)
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('4.0.0')
@skip_if_redis_enterprise
def test_module_list(self, r):
@@ -3675,10 +3800,11 @@ class TestRedisCommands:
def test_command(self, r):
res = r.command()
assert len(res) >= 100
- cmds = [c[0].decode() for c in res]
+ cmds = list(res.keys())
assert 'set' in cmds
assert 'get' in cmds
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('4.0.0')
@skip_if_redis_enterprise
def test_module(self, r):
@@ -3734,6 +3860,7 @@ class TestRedisCommands:
assert r.restore(key, 0, dumpdata, frequency=5)
assert r.get(key) == b'blee!'
+ @pytest.mark.onlynoncluster
@skip_if_server_version_lt('5.0.0')
@skip_if_redis_enterprise
def test_replicaof(self, r):
@@ -3742,6 +3869,7 @@ class TestRedisCommands:
assert r.replicaof("NO", "ONE")
+@pytest.mark.onlynoncluster
class TestBinarySave:
def test_binary_get_set(self, r):