1- """Unit tests for LangCacheWrapper ."""
1+ """Unit tests for LangCacheSemanticCache ."""
22
33import importlib .util
44from unittest .mock import AsyncMock , MagicMock , patch
55
66import pytest
77
8- from redisvl .extensions .cache .llm .langcache import LangCacheWrapper
8+ from redisvl .extensions .cache .llm .langcache import LangCacheSemanticCache
99
1010
1111@pytest .fixture
1212def mock_langcache_client ():
1313 """Create a mock LangCache client via the wrapper factory method."""
14- with patch .object (LangCacheWrapper , "_create_client" ) as mock_create_client :
14+ with patch .object (LangCacheSemanticCache , "_create_client" ) as mock_create_client :
1515 mock_client = MagicMock ()
1616 mock_create_client .return_value = mock_client
1717
@@ -28,13 +28,13 @@ def mock_langcache_client():
2828 importlib .util .find_spec ("langcache" ) is None ,
2929 reason = "langcache package not installed" ,
3030)
31- class TestLangCacheWrapper :
32- """Test suite for LangCacheWrapper ."""
31+ class TestLangCacheSemanticCache :
32+ """Test suite for LangCacheSemanticCache ."""
3333
3434 def test_init_requires_cache_id (self ):
3535 """Test that cache_id is required."""
3636 with pytest .raises (ValueError , match = "cache_id is required" ):
37- LangCacheWrapper (
37+ LangCacheSemanticCache (
3838 name = "test" ,
3939 server_url = "https://api.example.com" ,
4040 cache_id = "" ,
@@ -44,7 +44,7 @@ def test_init_requires_cache_id(self):
4444 def test_init_requires_api_key (self ):
4545 """Test that api_key is required."""
4646 with pytest .raises (ValueError , match = "api_key is required" ):
47- LangCacheWrapper (
47+ LangCacheSemanticCache (
4848 name = "test" ,
4949 server_url = "https://api.example.com" ,
5050 cache_id = "test-cache" ,
@@ -54,7 +54,7 @@ def test_init_requires_api_key(self):
5454 def test_init_requires_at_least_one_search_strategy (self ):
5555 """Test that at least one search strategy must be enabled."""
5656 with pytest .raises (ValueError , match = "At least one of use_exact_search" ):
57- LangCacheWrapper (
57+ LangCacheSemanticCache (
5858 name = "test" ,
5959 server_url = "https://api.example.com" ,
6060 cache_id = "test-cache" ,
@@ -67,7 +67,7 @@ def test_init_success(self, mock_langcache_client):
6767 """Test successful initialization."""
6868 mock_create_client , _ = mock_langcache_client
6969
70- cache = LangCacheWrapper (
70+ cache = LangCacheSemanticCache (
7171 name = "test_cache" ,
7272 server_url = "https://api.example.com" ,
7373 cache_id = "test-cache-id" ,
@@ -93,7 +93,7 @@ def test_store(self, mock_langcache_client):
9393 mock_response .entry_id = "entry-123"
9494 mock_client .set .return_value = mock_response
9595
96- cache = LangCacheWrapper (
96+ cache = LangCacheSemanticCache (
9797 name = "test" ,
9898 server_url = "https://api.example.com" ,
9999 cache_id = "test-cache" ,
@@ -123,7 +123,7 @@ async def test_astore(self, mock_langcache_client):
123123 mock_response .entry_id = "entry-456"
124124 mock_client .set_async = AsyncMock (return_value = mock_response )
125125
126- cache = LangCacheWrapper (
126+ cache = LangCacheSemanticCache (
127127 name = "test" ,
128128 server_url = "https://api.example.com" ,
129129 cache_id = "test-cache" ,
@@ -158,7 +158,7 @@ def test_check(self, mock_langcache_client):
158158 mock_response .data = [mock_entry ]
159159 mock_client .search .return_value = mock_response
160160
161- cache = LangCacheWrapper (
161+ cache = LangCacheSemanticCache (
162162 name = "test" ,
163163 server_url = "https://api.example.com" ,
164164 cache_id = "test-cache" ,
@@ -198,7 +198,7 @@ async def test_acheck(self, mock_langcache_client):
198198 mock_response .data = [mock_entry ]
199199 mock_client .search_async = AsyncMock (return_value = mock_response )
200200
201- cache = LangCacheWrapper (
201+ cache = LangCacheSemanticCache (
202202 name = "test" ,
203203 server_url = "https://api.example.com" ,
204204 cache_id = "test-cache" ,
@@ -232,7 +232,7 @@ def test_check_with_distance_threshold(self, mock_langcache_client):
232232 mock_response .data = [mock_entry ]
233233 mock_client .search .return_value = mock_response
234234
235- cache = LangCacheWrapper (
235+ cache = LangCacheSemanticCache (
236236 name = "test" ,
237237 server_url = "https://api.example.com" ,
238238 cache_id = "test-cache" ,
@@ -268,7 +268,7 @@ def test_check_with_attributes(self, mock_langcache_client):
268268 mock_response .data = [mock_entry ]
269269 mock_client .search .return_value = mock_response
270270
271- cache = LangCacheWrapper (
271+ cache = LangCacheSemanticCache (
272272 name = "test" ,
273273 server_url = "https://api.example.com" ,
274274 cache_id = "test-cache" ,
@@ -296,7 +296,7 @@ def test_delete(self, mock_langcache_client):
296296 """Test deleting the entire cache."""
297297 _ , mock_client = mock_langcache_client
298298
299- cache = LangCacheWrapper (
299+ cache = LangCacheSemanticCache (
300300 name = "test" ,
301301 server_url = "https://api.example.com" ,
302302 cache_id = "test-cache" ,
@@ -314,7 +314,7 @@ async def test_adelete(self, mock_langcache_client):
314314
315315 mock_client .delete_query_async = AsyncMock ()
316316
317- cache = LangCacheWrapper (
317+ cache = LangCacheSemanticCache (
318318 name = "test" ,
319319 server_url = "https://api.example.com" ,
320320 cache_id = "test-cache" ,
@@ -329,7 +329,7 @@ def test_delete_by_id(self, mock_langcache_client):
329329 """Test deleting a single entry by ID."""
330330 _ , mock_client = mock_langcache_client
331331
332- cache = LangCacheWrapper (
332+ cache = LangCacheSemanticCache (
333333 name = "test" ,
334334 server_url = "https://api.example.com" ,
335335 cache_id = "test-cache" ,
@@ -342,7 +342,7 @@ def test_delete_by_id(self, mock_langcache_client):
342342
343343 def test_update_not_supported (self , mock_langcache_client ):
344344 """Test that update raises NotImplementedError."""
345- cache = LangCacheWrapper (
345+ cache = LangCacheSemanticCache (
346346 name = "test" ,
347347 server_url = "https://api.example.com" ,
348348 cache_id = "test-cache" ,
@@ -355,7 +355,7 @@ def test_update_not_supported(self, mock_langcache_client):
355355 @pytest .mark .asyncio
356356 async def test_aupdate_not_supported (self , mock_langcache_client ):
357357 """Test that async update raises NotImplementedError."""
358- cache = LangCacheWrapper (
358+ cache = LangCacheSemanticCache (
359359 name = "test" ,
360360 server_url = "https://api.example.com" ,
361361 cache_id = "test-cache" ,
@@ -373,7 +373,7 @@ def test_import_error_when_langcache_not_installed():
373373 pytest .skip ("langcache package is installed" )
374374
375375 with pytest .raises (ImportError , match = "langcache package is required" ):
376- LangCacheWrapper (
376+ LangCacheSemanticCache (
377377 name = "test" ,
378378 server_url = "https://api.example.com" ,
379379 cache_id = "test-cache" ,
0 commit comments