6
6
from redis .exceptions import ConnectionError
7
7
8
8
from redisvl .redis .connection import RedisConnectionFactory , get_address_from_env
9
+ from redisvl .version import __version__
10
+
11
+ EXPECTED_LIB_NAME = f"redis-py(redisvl_v{ __version__ } )"
9
12
10
13
11
14
def test_get_address_from_env (redis_url ):
12
15
assert get_address_from_env () == redis_url
13
16
14
17
15
- def test_sync_redis_connection (redis_url ):
18
+ def test_sync_redis_connect (redis_url ):
16
19
client = RedisConnectionFactory .connect (redis_url )
17
20
assert client is not None
18
21
assert isinstance (client , Redis )
@@ -21,7 +24,7 @@ def test_sync_redis_connection(redis_url):
21
24
22
25
23
26
@pytest .mark .asyncio
24
- async def test_async_redis_connection (redis_url ):
27
+ async def test_async_redis_connect (redis_url ):
25
28
client = RedisConnectionFactory .connect (redis_url , use_async = True )
26
29
assert client is not None
27
30
assert isinstance (client , AsyncRedis )
@@ -49,11 +52,29 @@ def test_unknown_redis():
49
52
bad_client .ping ()
50
53
51
54
52
- def test_required_modules (client ):
53
- RedisConnectionFactory .validate_redis_modules (client )
55
+ def test_validate_redis (client ):
56
+ RedisConnectionFactory .validate_redis (client )
57
+ lib_name = client .client_info ()
58
+ assert lib_name ["lib-name" ] == EXPECTED_LIB_NAME
59
+
60
+
61
+ @pytest .mark .asyncio
62
+ async def test_validate_async_redis (async_client ):
63
+ client = await async_client
64
+ RedisConnectionFactory .validate_async_redis (client )
65
+ lib_name = await client .client_info ()
66
+ assert lib_name ["lib-name" ] == EXPECTED_LIB_NAME
67
+
68
+
69
+ def test_custom_lib_name (client ):
70
+ RedisConnectionFactory .validate_redis (client , "langchain_v0.1.0" )
71
+ lib_name = client .client_info ()
72
+ assert lib_name ["lib-name" ] == f"redis-py(redisvl_v{ __version__ } ;langchain_v0.1.0)"
54
73
55
74
56
75
@pytest .mark .asyncio
57
- async def test_async_required_modules (async_client ):
76
+ async def test_async_custom_lib_name (async_client ):
58
77
client = await async_client
59
- RedisConnectionFactory .validate_async_redis_modules (client )
78
+ RedisConnectionFactory .validate_async_redis (client , "langchain_v0.1.0" )
79
+ lib_name = await client .client_info ()
80
+ assert lib_name ["lib-name" ] == f"redis-py(redisvl_v{ __version__ } ;langchain_v0.1.0)"
0 commit comments