Skip to content

Commit

Permalink
feat: add test for single route single utterance
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescalam committed Dec 15, 2024
1 parent 7582332 commit cee97c9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/unit/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ def routes_4():
Route(name="Route 2", utterances=["Asparagus"]),
]

@pytest.fixture
def route_single_utterance():
return [
Route(name="Route 1", utterances=["Hello"]),
]

@pytest.fixture
def dynamic_routes():
Expand Down Expand Up @@ -251,6 +256,21 @@ def test_initialization_dynamic_route(
)
assert route_layer.score_threshold == openai_encoder.score_threshold

def test_initialization_single_utterance(
self, route_single_utterance, openai_encoder, index_cls
):
index = init_index(index_cls)
route_layer = SemanticRouter(
encoder=openai_encoder,
routes=route_single_utterance,
index=index,
auto_sync="local",
)
assert route_layer.score_threshold == openai_encoder.score_threshold
if index_cls is PineconeIndex:
time.sleep(PINECONE_SLEEP) # allow for index to be updated
assert len(route_layer.index.get_utterances()) == 1

def test_delete_index(self, openai_encoder, routes, index_cls):
# TODO merge .delete_index() and .delete_all() and get working
index = init_index(index_cls)
Expand Down

0 comments on commit cee97c9

Please sign in to comment.