1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
From: Colin Watson <cjwatson@debian.org>
Date: Thu, 10 Apr 2025 15:17:32 +0100
Subject: Adjust tests for redis-server < 7.2
Last-Update: 2025-04-10
---
tests/test_asyncio/test_cluster.py | 7 ++++++-
tests/test_asyncio/test_commands.py | 7 ++++++-
tests/test_cluster.py | 7 ++++++-
tests/test_commands.py | 7 ++++++-
4 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/tests/test_asyncio/test_cluster.py b/tests/test_asyncio/test_cluster.py
index 25f487f..319e159 100644
--- a/tests/test_asyncio/test_cluster.py
+++ b/tests/test_asyncio/test_cluster.py
@@ -10,6 +10,7 @@ from urllib.parse import urlparse
import pytest
import pytest_asyncio
from _pytest.fixtures import FixtureRequest
+from packaging.version import Version
from redis._parsers import AsyncCommandsParser
from redis.asyncio.cluster import ClusterNode, NodesManager, RedisCluster
from redis.asyncio.connection import Connection, SSLConnection, async_timeout
@@ -41,6 +42,7 @@ from redis.exceptions import (
)
from redis.utils import str_if_bytes
from tests.conftest import (
+ REDIS_INFO,
assert_resp_response,
is_resp2_connection,
skip_if_redis_enterprise,
@@ -2415,7 +2417,10 @@ class TestClusterRedisCommands:
await user_client.hset("{cache}:0", "hkey", "hval")
assert isinstance(await r.acl_log(target_nodes=node), list)
- assert len(await r.acl_log(target_nodes=node)) == 3
+ if Version(REDIS_INFO.get("version", "0")) >= Version("7.2.0"):
+ assert len(await r.acl_log(target_nodes=node)) == 3
+ else:
+ assert len(await r.acl_log(target_nodes=node)) == 2
assert len(await r.acl_log(count=1, target_nodes=node)) == 1
assert isinstance((await r.acl_log(target_nodes=node))[0], dict)
assert "client-info" in (await r.acl_log(count=1, target_nodes=node))[0]
diff --git a/tests/test_asyncio/test_commands.py b/tests/test_asyncio/test_commands.py
index 9db7d20..cc7b9a6 100644
--- a/tests/test_asyncio/test_commands.py
+++ b/tests/test_asyncio/test_commands.py
@@ -12,6 +12,7 @@ from string import ascii_letters
import pytest
import pytest_asyncio
import redis
+from packaging.version import Version
from redis import exceptions
from redis._parsers.helpers import (
_RedisCallbacks,
@@ -24,6 +25,7 @@ from redis.commands.json.path import Path
from redis.commands.search.field import TextField
from redis.commands.search.query import Query
from tests.conftest import (
+ REDIS_INFO,
assert_resp_response,
assert_resp_response_in,
is_resp2_connection,
@@ -331,7 +333,10 @@ class TestRedisCommands:
await user_client.hset("cache:0", "hkey", "hval")
assert isinstance(await r.acl_log(), list)
- assert len(await r.acl_log()) == 3
+ if Version(REDIS_INFO.get("version", "0")) >= Version("7.2.0"):
+ assert len(await r.acl_log()) == 3
+ else:
+ assert len(await r.acl_log()) == 2
assert len(await r.acl_log(count=1)) == 1
assert isinstance((await r.acl_log())[0], dict)
expected = (await r.acl_log(count=1))[0]
diff --git a/tests/test_cluster.py b/tests/test_cluster.py
index 4883ba6..092388d 100644
--- a/tests/test_cluster.py
+++ b/tests/test_cluster.py
@@ -12,6 +12,7 @@ from unittest.mock import DEFAULT, Mock, call, patch
import pytest
import redis
+from packaging.version import Version
from redis import Redis
from redis._parsers import CommandsParser
from redis.backoff import (
@@ -48,6 +49,7 @@ from redis.utils import str_if_bytes
from tests.test_pubsub import wait_for_message
from .conftest import (
+ REDIS_INFO,
_get_client,
assert_resp_response,
is_resp2_connection,
@@ -2516,7 +2518,10 @@ class TestClusterRedisCommands:
user_client.hset("{cache}:0", "hkey", "hval")
assert isinstance(r.acl_log(target_nodes=node), list)
- assert len(r.acl_log(target_nodes=node)) == 3
+ if Version(REDIS_INFO.get("version", "0")) >= Version("7.2.0"):
+ assert len(r.acl_log(target_nodes=node)) == 3
+ else:
+ assert len(r.acl_log(target_nodes=node)) == 2
assert len(r.acl_log(count=1, target_nodes=node)) == 1
assert isinstance(r.acl_log(target_nodes=node)[0], dict)
assert "client-info" in r.acl_log(count=1, target_nodes=node)[0]
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 42530a4..5d4e7ec 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -10,6 +10,7 @@ from unittest.mock import patch
import pytest
import redis
+from packaging.version import Version
from redis import exceptions
from redis._parsers.helpers import (
_RedisCallbacks,
@@ -24,6 +25,7 @@ from redis.commands.search.query import Query
from tests.test_utils import redis_server_time
from .conftest import (
+ REDIS_INFO,
_get_client,
assert_resp_response,
assert_resp_response_in,
@@ -448,7 +450,10 @@ class TestRedisCommands:
user_client.hset("cache:0", "hkey", "hval")
assert isinstance(r.acl_log(), list)
- assert len(r.acl_log()) == 3
+ if Version(REDIS_INFO.get("version", "0")) >= Version("7.2.0"):
+ assert len(r.acl_log()) == 3
+ else:
+ assert len(r.acl_log()) == 2
assert len(r.acl_log(count=1)) == 1
assert isinstance(r.acl_log()[0], dict)
expected = r.acl_log(count=1)[0]
|