Skip to content

Commit

Permalink
fixed unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
epinzur committed Oct 15, 2024
1 parent 26e4475 commit a0a8262
Showing 1 changed file with 57 additions and 6 deletions.
63 changes: 57 additions & 6 deletions libs/astradb/tests/unit_tests/test_callers.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,63 @@ def test_callers_component_vectorstore(self, httpserver: HTTPServer) -> None:
ext_callers=[("ec0", "ev0")],
)

def test_callers_component_graphvectorstore(self, httpserver: HTTPServer) -> None:
"""
End-to-end testing of callers passed through the components.
The graphvectorstore, which can also do autodetect operations,
requires separate handling.
"""
base_endpoint = httpserver.url_for("/")
base_path = "/v1/ks"

# through the init flow
httpserver.expect_oneshot_request(
base_path,
method="POST",
headers={
"User-Agent": "ec0/ev0",
},
header_value_matcher=hv_prefix_matcher_factory(
COMPONENT_NAME_GRAPHVECTORSTORE
),
).respond_with_json({})

# the metadata_search test call
httpserver.expect_oneshot_request(
base_path + "/my_graph_coll",
method="POST",
headers={
"User-Agent": "ec0/ev0",
},
header_value_matcher=hv_prefix_matcher_factory(
COMPONENT_NAME_GRAPHVECTORSTORE
),
).respond_with_json(
{
"status": {
"collections": [
{
"name": "my_graph_coll",
"options": {"vector": {"dimension": 2}},
}
]
},
"data": {
"nextPageState": None,
"documents": [],
},
}
)

AstraDBGraphVectorStore(
collection_name="my_graph_coll",
api_endpoint=base_endpoint,
environment=Environment.OTHER,
namespace="ks",
embedding=ParserEmbeddings(2),
ext_callers=[("ec0", "ev0")],
)

@pytest.mark.parametrize(
("component_class", "component_name", "kwargs"),
[
Expand All @@ -304,11 +361,6 @@ def test_callers_component_vectorstore(self, httpserver: HTTPServer) -> None:
COMPONENT_NAME_CHATMESSAGEHISTORY,
{"session_id": "x"},
),
(
AstraDBGraphVectorStore,
COMPONENT_NAME_GRAPHVECTORSTORE,
{"embedding": ParserEmbeddings(2)},
),
(
AstraDBSemanticCache,
COMPONENT_NAME_SEMANTICCACHE,
Expand All @@ -320,7 +372,6 @@ def test_callers_component_vectorstore(self, httpserver: HTTPServer) -> None:
"Byte store",
"Cache",
"Chat message history",
"Graph vector store",
"Semantic cache",
"Store",
],
Expand Down

0 comments on commit a0a8262

Please sign in to comment.