From 231d553824ac0b296cfc017a6579a44c0eede8f2 Mon Sep 17 00:00:00 2001 From: Tyler Hutcherson Date: Thu, 26 Oct 2023 19:13:14 -0400 Subject: [PATCH] Update broken redis tests (#12371) Update broken redis tests -- tiny PR :) - **Description:** Fixes Redis tests on master (look like it was broken by https://github.com/langchain-ai/langchain/pull/11257) - **Issue:** None, - **Dependencies:** No - **Tag maintainer:** @baskaryan @Spartee - **Twitter handle:** N/A Co-authored-by: Sam Partee --- .../integration_tests/vectorstores/test_redis.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libs/langchain/tests/integration_tests/vectorstores/test_redis.py b/libs/langchain/tests/integration_tests/vectorstores/test_redis.py index 6128a8445ae..28d524843ab 100644 --- a/libs/langchain/tests/integration_tests/vectorstores/test_redis.py +++ b/libs/langchain/tests/integration_tests/vectorstores/test_redis.py @@ -141,7 +141,8 @@ def test_custom_keys(texts: List[str]) -> None: docsearch, keys_out = Redis.from_texts_return_keys( texts, FakeEmbeddings(), redis_url=TEST_REDIS_URL, keys=keys_in ) - assert keys_in == keys_out + # it will append the index key prefix to all keys + assert keys_out == [docsearch.key_prefix + ":" + key for key in keys_in] assert drop(docsearch.index_name) @@ -154,11 +155,13 @@ def test_custom_keys_from_docs(texts: List[str]) -> None: ) client = docsearch.client # test keys are correct - assert client.hget("test_key_1", "content") + assert client.hget(docsearch.key_prefix + ":" + "test_key_1", "content") # test metadata is stored - assert client.hget("test_key_1", "a") == bytes("b", "utf-8") + assert client.hget(docsearch.key_prefix + ":" + "test_key_1", "a") == bytes( + "b", "utf-8" + ) # test all keys are stored - assert client.hget("test_key_2", "content") + assert client.hget(docsearch.key_prefix + ":" + "test_key_2", "content") assert drop(docsearch.index_name)