diff options
author | Avital Fine <79420960+AvitalFineRedis@users.noreply.github.com> | 2021-07-22 18:51:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-22 18:51:24 +0300 |
commit | 627db540acd1f1f36db88290d74cbcd75f6bda0c (patch) | |
tree | cefd359cf225baead43a7beaca78a5c8f84d4c33 /tests/test_commands.py | |
parent | ad4779eb8200e47a7786f78ca915a246038602c3 (diff) | |
download | redis-py-627db540acd1f1f36db88290d74cbcd75f6bda0c.tar.gz |
hrandfield (#1513)
* hrandfield
* use mapping in hset
* skip if version not fit
* remove empty line
* flake8 comments
* new line for each comment
Diffstat (limited to 'tests/test_commands.py')
-rw-r--r-- | tests/test_commands.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py index 9884035..27117e3 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -895,6 +895,19 @@ class TestRedisCommands: "PTTL on servers 2.8 and after return -2 when the key doesn't exist" assert r.pttl('a') == -2 + @skip_if_server_version_lt('6.2.0') + def test_hrandfield(self, r): + assert r.hrandfield('key') is None + r.hset('key', mapping={'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}) + assert r.hrandfield('key') is not None + assert len(r.hrandfield('key', 2)) == 2 + # with values + assert len(r.hrandfield('key', 2, True)) == 4 + # without duplications + assert len(r.hrandfield('key', 10)) == 5 + # with duplications + assert len(r.hrandfield('key', -10)) == 10 + def test_randomkey(self, r): assert r.randomkey() is None for key in ('a', 'b', 'c'): |