Skip to content

Commit 4b29585

Browse files
authored
Fix #659 - Add port to distinguish redis instances (#670)
1 parent 2e08213 commit 4b29585

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

health_check/contrib/redis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __repr__(self):
6767
for key, value in sorted(
6868
client.connection_pool.connection_kwargs.items()
6969
)
70-
if key in {"host", "db"}
70+
if key in {"host", "port", "db"}
7171
)
7272
return f"Redis({safe_connection_str})"
7373
except AttributeError:

tests/contrib/test_redis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,13 @@ async def test_redis__validation_neither_param(self):
151151

152152
def test_redis__repr_standard_client(self):
153153
"""Verify repr includes host and db for a standard Redis client."""
154+
# https://github.com/codingjoe/django-health-check/issues/659
154155
from redis.asyncio import Redis as RedisClient
155156

156157
check = RedisHealthCheck(
157158
client_factory=lambda: RedisClient(host="myhost", port=6379, db=2)
158159
)
159-
assert repr(check) == "Redis(db=2, host='myhost')"
160+
assert repr(check) == "Redis(db=2, host='myhost', port=6379)"
160161

161162
def test_redis__repr_from_url(self):
162163
"""Verify repr includes host and db when client is created via from_url."""

0 commit comments

Comments
 (0)