Skip to content

Commit

Permalink
test invalid client type
Browse files Browse the repository at this point in the history
  • Loading branch information
hsm207 committed Feb 7, 2024
1 parent 0c9b4e4 commit 8f5b8bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions langchain_weaviate/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def __init__(

if not isinstance(client, weaviate.WeaviateClient):
raise ValueError(
"client should be an instance of "
"weaviate.WeaviateClient, got {type(client)}"
f"client should be an instance of weaviate.WeaviateClient, got {type(client)}"
)
self._client = client
self._index_name = index_name or f"LangChain_{uuid4().hex}"
Expand Down
18 changes: 18 additions & 0 deletions tests/integration_tests/test_vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,21 @@ def test_search_with_multi_tenancy(
ValueError, match="has multi-tenancy enabled, but request was without tenant"
):
docsearch.similarity_search("foo", k=1)


def test_invalid_client_type():
with pytest.raises(ValueError) as excinfo:
invalid_client = "invalid_client"
index_name = "test_index"
text_key = "text"

WeaviateVectorStore(
client=invalid_client,
index_name=index_name,
text_key=text_key,
)

assert (
str(excinfo.value)
== "client should be an instance of weaviate.WeaviateClient, got <class 'str'>"
)

0 comments on commit 8f5b8bf

Please sign in to comment.