Skip to content

Commit 9bdcb46

Browse files
committed
Resolving review feedback
1 parent 47a4473 commit 9bdcb46

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

tests/integration/test_langcache_semantic_cache_integration.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
from typing import Dict
1818

1919
import pytest
20+
from dotenv import load_dotenv
2021
from langcache.errors import BadRequestErrorResponseContent
2122

2223
from redisvl.extensions.cache.llm.langcache import LangCacheSemanticCache
2324

25+
load_dotenv()
26+
2427
REQUIRED_WITH_ATTRS_VARS = (
2528
"LANGCACHE_WITH_ATTRIBUTES_API_KEY",
2629
"LANGCACHE_WITH_ATTRIBUTES_CACHE_ID",
@@ -235,13 +238,31 @@ async def test_async_delete_variants(
235238
)
236239
assert not any(hit["response"] == response for hit in hits_after_clear)
237240

241+
def test_attribute_value_with_comma_passes_through_to_api(
242+
self, langcache_with_attrs: LangCacheSemanticCache
243+
) -> None:
244+
"""We currently rely on the LangCache API to validate commas in attribute values.
245+
246+
This test verifies we do not perform client-side validation and that the
247+
error is raised by the backend. If this behavior changes, this test will
248+
need to be updated.
249+
"""
250+
prompt = "Comma attribute value"
251+
response = "This may fail depending on the remote validation rules."
252+
253+
with pytest.raises(BadRequestErrorResponseContent):
254+
langcache_with_attrs.store(
255+
prompt=prompt,
256+
response=response,
257+
metadata={"llm_string": "tenant,with,comma"},
258+
)
259+
238260

239261
@pytest.mark.requires_api_keys
240262
class TestLangCacheSemanticCacheIntegrationWithoutAttributes:
241263
def test_error_on_store_with_metadata_when_no_attributes_configured(
242264
self, langcache_no_attrs: LangCacheSemanticCache
243265
) -> None:
244-
245266
prompt = "Attributes not configured"
246267
response = "This should fail due to missing attributes configuration."
247268

@@ -279,22 +300,3 @@ def test_basic_store_and_check_works_without_attributes(
279300
hits = langcache_no_attrs.check(prompt=prompt)
280301
assert hits
281302
assert any(hit["response"] == response for hit in hits)
282-
283-
def test_attribute_value_with_comma_passes_through_to_api(
284-
self, langcache_with_attrs: LangCacheSemanticCache
285-
) -> None:
286-
"""We currently rely on the LangCache API to validate commas in attribute values.
287-
288-
This test verifies we do not perform client-side validation and that the
289-
error is raised by the backend. If this behavior changes, this test will
290-
need to be updated.
291-
"""
292-
prompt = "Comma attribute value"
293-
response = "This may fail depending on the remote validation rules."
294-
295-
with pytest.raises(BadRequestErrorResponseContent):
296-
langcache_with_attrs.store(
297-
prompt=prompt,
298-
response=response,
299-
metadata={"llm_string": "tenant,with,comma"},
300-
)

0 commit comments

Comments
 (0)