summaryrefslogtreecommitdiff
path: root/tests/cache/tests.py
diff options
context:
space:
mode:
authorar3ph <192461522+ar3ph@users.noreply.github.com>2026-02-02 13:26:18 -0500
committerJacob Walls <jacobtylerwalls@gmail.com>2026-02-03 06:40:29 -0500
commit72ae25a9c2bb1a9e369e52e696a8b7d1a8df245e (patch)
treefa3453118bfe116bb393153be80f6f52b1062add /tests/cache/tests.py
parent24a14860ced5c456522d69c16afd2c631cc0456f (diff)
Fixed #36879 -- Identified Django client in Redis client metadata.
Diffstat (limited to 'tests/cache/tests.py')
-rw-r--r--tests/cache/tests.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py
index db5df20701..b36e3a6a06 100644
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -15,6 +15,7 @@ from functools import wraps
from pathlib import Path
from unittest import mock, skipIf
+import django
from django.conf import settings
from django.core import management, signals
from django.core.cache import (
@@ -1986,6 +1987,24 @@ class RedisCacheTests(BaseCacheTests, TestCase):
self.assertEqual(pool.connection_kwargs["socket_timeout"], 0.1)
self.assertIs(pool.connection_kwargs["retry_on_timeout"], True)
+ def test_client_driver_info(self):
+ client_info = cache._cache.get_client().client_info()
+ if {"lib-name", "lib-ver"}.issubset(client_info):
+ version = django.get_version()
+ if hasattr(self.lib, "DriverInfo"):
+ info = self._lib.DriverInfo().add_upstream_driver("django", version)
+ correct_lib_name = info.formatted_name
+ else:
+ correct_lib_name = f"redis-py(django_v{version})"
+ # Relax the assertion to allow date variance in editable installs.
+ truncated_lib_name = correct_lib_name.rsplit(".dev", maxsplit=1)[0]
+ self.assertIn(truncated_lib_name, client_info["lib-name"])
+ self.assertEqual(client_info["lib-ver"], self.lib.__version__)
+ else:
+ # Redis versions below 7.2 lack CLIENT SETINFO.
+ self.assertNotIn("lib-ver", client_info)
+ self.assertNotIn("lib-name", client_info)
+
class FileBasedCachePathLibTests(FileBasedCacheTests):
def mkdtemp(self):