From 2c405855021ccc8d4a45fa1aae352ddb303baae0 Mon Sep 17 00:00:00 2001 From: dogukanteber <47397379+dogukanteber@users.noreply.github.com> Date: Mon, 14 Mar 2022 16:02:46 +0300 Subject: Add support for EXPIRE command's options (#2002) * Add support for EXPIRE command's options * Add requested changes * Change method arguments * add variables to the function header Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com> Co-authored-by: Chayim Co-authored-by: dvora-h --- tests/test_commands.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/test_commands.py') diff --git a/tests/test_commands.py b/tests/test_commands.py index a73541e..c8bcc9c 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1058,6 +1058,31 @@ class TestRedisCommands: assert r.persist("a") assert r.ttl("a") == -1 + @skip_if_server_version_lt("7.0.0") + def test_expire_option_nx(self, r): + r.set("key", "val") + assert r.expire("key", 100, nx=True) == 1 + assert r.expire("key", 500, nx=True) == 0 + + @skip_if_server_version_lt("7.0.0") + def test_expire_option_xx(self, r): + r.set("key", "val") + assert r.expire("key", 100, xx=True) == 0 + assert r.expire("key", 100) + assert r.expire("key", 500, nx=True) == 1 + + @skip_if_server_version_lt("7.0.0") + def test_expire_option_gt(self, r): + r.set("key", "val", 100) + assert r.expire("key", 50, gt=True) == 0 + assert r.expire("key", 500, gt=True) == 1 + + @skip_if_server_version_lt("7.0.0") + def test_expire_option_lt(self, r): + r.set("key", "val", 100) + assert r.expire("key", 50, lt=True) == 1 + assert r.expire("key", 150, lt=True) == 0 + def test_expireat_datetime(self, r): expire_at = redis_server_time(r) + datetime.timedelta(minutes=1) r["a"] = "foo" -- cgit v1.2.1