@@ -285,7 +285,10 @@ async def test_from_conn_string_cleanup(redis_url: str) -> None:
285285@pytest .mark .asyncio
286286async def test_async_client_info_setting (redis_url : str , monkeypatch ) -> None :
287287 """Test that async client_setinfo is called with correct library information."""
288- from langgraph .checkpoint .redis .version import __full_lib_name__
288+ from langgraph .checkpoint .redis .version import __redisvl_version__
289+
290+ # Expected client info format
291+ expected_client_info = f"redis-py(redisvl_v{ __redisvl_version__ } )"
289292
290293 # Track if client_setinfo was called with the right parameters
291294 client_info_called = False
@@ -298,7 +301,7 @@ async def mock_client_setinfo(self, key, value):
298301 nonlocal client_info_called
299302 # Note: RedisVL might call this with its own lib name first
300303 # We only track calls with our full lib name
301- if key == "LIB-NAME" and __full_lib_name__ in value :
304+ if key == "LIB-NAME" and value == expected_client_info :
302305 client_info_called = True
303306 # Call original method to ensure normal function
304307 return await original_client_setinfo (self , key , value )
@@ -320,7 +323,10 @@ async def test_async_client_info_fallback_to_echo(redis_url: str, monkeypatch) -
320323 """Test that async client_setinfo falls back to echo when not available."""
321324 from redis .exceptions import ResponseError
322325
323- from langgraph .checkpoint .redis .version import __full_lib_name__
326+ from langgraph .checkpoint .redis .version import __redisvl_version__
327+
328+ # Expected client info format
329+ expected_client_info = f"redis-py(redisvl_v{ __redisvl_version__ } )"
324330
325331 # Remove client_setinfo to simulate older Redis version
326332 async def mock_client_setinfo (self , key , value ):
@@ -334,7 +340,7 @@ async def mock_client_setinfo(self, key, value):
334340 async def mock_echo (self , message ):
335341 nonlocal echo_called
336342 echo_called = True
337- assert message == __full_lib_name__
343+ assert message == expected_client_info
338344 return await original_echo (self , message )
339345
340346 # Apply the mocks
@@ -357,14 +363,25 @@ async def test_async_client_info_graceful_failure(redis_url: str, monkeypatch) -
357363 """Test that async client info setting fails gracefully when all methods fail."""
358364 from redis .exceptions import ResponseError
359365
366+ # Create a patch for the RedisVL validation to avoid it using echo
367+ from redisvl .redis .connection import RedisConnectionFactory
368+ original_validate = RedisConnectionFactory .validate_async_redis
369+
370+ # Create a replacement validation function that doesn't use echo
371+ async def mock_validate (redis_client , lib_name = None ):
372+ return redis_client
373+
374+ # Apply the validation mock first to prevent echo from being called by RedisVL
375+ monkeypatch .setattr (RedisConnectionFactory , "validate_async_redis" , mock_validate )
376+
360377 # Simulate failures for both methods
361378 async def mock_client_setinfo (self , key , value ):
362379 raise ResponseError ("ERR unknown command" )
363380
364381 async def mock_echo (self , message ):
365382 raise ResponseError ("ERR connection broken" )
366383
367- # Apply the mocks
384+ # Apply the Redis mocks
368385 monkeypatch .setattr (Redis , "client_setinfo" , mock_client_setinfo )
369386 monkeypatch .setattr (Redis , "echo" , mock_echo )
370387
0 commit comments