diff options
Diffstat (limited to 'tests/test_commands.py')
-rw-r--r-- | tests/test_commands.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py index 15a76de..7f1e33e 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -59,7 +59,6 @@ class TestResponseCallbacks(object): class TestRedisCommands(object): - def test_command_on_invalid_key_type(self, r): r.lpush('a', '1') with pytest.raises(redis.ResponseError): @@ -1102,7 +1101,7 @@ class TestRedisCommands(object): @skip_if_server_version_lt('2.8.0') def test_hscan(self, r): - r.hmset('a', {'a': 1, 'b': 2, 'c': 3}) + r.hset('a', mapping={'a': 1, 'b': 2, 'c': 3}) cursor, dic = r.hscan('a') assert cursor == 0 assert dic == {b'a': b'1', b'b': b'2', b'c': b'3'} @@ -1111,7 +1110,7 @@ class TestRedisCommands(object): @skip_if_server_version_lt('2.8.0') def test_hscan_iter(self, r): - r.hmset('a', {'a': 1, 'b': 2, 'c': 3}) + r.hset('a', mapping={'a': 1, 'b': 2, 'c': 3}) dic = dict(r.hscan_iter('a')) assert dic == {b'a': b'1', b'b': b'2', b'c': b'3'} dic = dict(r.hscan_iter('a', match='a')) @@ -1587,7 +1586,7 @@ class TestRedisCommands(object): # HASH COMMANDS def test_hget_and_hset(self, r): - r.hmset('a', mapping={'1': 1, '2': 2, '3': 3}) + r.hset('a', mapping={'1': 1, '2': 2, '3': 3}) assert r.hget('a', '1') == b'1' assert r.hget('a', '2') == b'2' assert r.hget('a', '3') == b'3' @@ -1619,20 +1618,20 @@ class TestRedisCommands(object): r.hset("x") def test_hdel(self, r): - r.hmset('a', {'1': 1, '2': 2, '3': 3}) + r.hset('a', mapping={'1': 1, '2': 2, '3': 3}) assert r.hdel('a', '2') == 1 assert r.hget('a', '2') is None assert r.hdel('a', '1', '3') == 2 assert r.hlen('a') == 0 def test_hexists(self, r): - r.hmset('a', {'1': 1, '2': 2, '3': 3}) + r.hset('a', mapping={'1': 1, '2': 2, '3': 3}) assert r.hexists('a', '1') assert not r.hexists('a', '4') def test_hgetall(self, r): h = {b'a1': b'1', b'a2': b'2', b'a3': b'3'} - r.hmset('a', h) + r.hset('a', mapping=h) assert r.hgetall('a') == h def test_hincrby(self, r): @@ -1648,22 +1647,25 @@ class TestRedisCommands(object): def test_hkeys(self, r): h = {b'a1': b'1', b'a2': b'2', b'a3': b'3'} - r.hmset('a', h) + r.hset('a', mapping=h) local_keys = list(iterkeys(h)) remote_keys = r.hkeys('a') assert (sorted(local_keys) == sorted(remote_keys)) def test_hlen(self, r): - r.hmset('a', {'1': 1, '2': 2, '3': 3}) + r.hset('a', mapping={'1': 1, '2': 2, '3': 3}) assert r.hlen('a') == 3 def test_hmget(self, r): - assert r.hmset('a', {'a': 1, 'b': 2, 'c': 3}) + assert r.hset('a', mapping={'a': 1, 'b': 2, 'c': 3}) 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\.$') h = {b'a': b'1', b'b': b'2', b'c': b'3'} - assert r.hmset('a', h) + with pytest.warns(DeprecationWarning, match=warning_message): + assert r.hmset('a', h) assert r.hgetall('a') == h def test_hsetnx(self, r): @@ -1675,14 +1677,14 @@ class TestRedisCommands(object): def test_hvals(self, r): h = {b'a1': b'1', b'a2': b'2', b'a3': b'3'} - r.hmset('a', h) + r.hset('a', mapping=h) local_vals = list(itervalues(h)) remote_vals = r.hvals('a') assert sorted(local_vals) == sorted(remote_vals) @skip_if_server_version_lt('3.2.0') def test_hstrlen(self, r): - r.hmset('a', {'1': '22', '2': '333'}) + r.hset('a', mapping={'1': '22', '2': '333'}) assert r.hstrlen('a', '1') == 2 assert r.hstrlen('a', '2') == 3 |