|
1 | | -"""Unit tests for QdrantIndex — uses in-memory or file-based Qdrant, no server needed.""" |
2 | | -import sys |
| 1 | +"""Unit tests for QdrantIndex — uses in-memory Qdrant, no server needed.""" |
3 | 2 | import uuid |
4 | | -from pathlib import Path |
5 | 3 |
|
6 | 4 | import numpy as np |
7 | 5 | import pytest |
8 | | - |
9 | | -# Ensure the local development copy of semantic-router takes precedence over any |
10 | | -# installed version so tests always exercise the code in this repo. |
11 | | -_repo_root = str(Path(__file__).resolve().parents[2]) |
12 | | -if _repo_root not in sys.path: |
13 | | - sys.path.insert(0, _repo_root) |
14 | | - |
15 | | -pytest.importorskip("qdrant_client", reason="qdrant-client not installed") |
16 | | - |
17 | 6 | from qdrant_client import models |
18 | 7 |
|
19 | 8 | from semantic_router.index.qdrant import ( |
20 | 9 | SR_ROUTE_PAYLOAD_KEY, |
21 | | - SR_UTTERANCE_PAYLOAD_KEY, |
22 | 10 | QdrantIndex, |
23 | 11 | ) |
24 | 12 |
|
| 13 | +pytest.importorskip("qdrant_client", reason="qdrant-client not installed") |
| 14 | + |
25 | 15 | DIMS = 4 |
26 | 16 |
|
27 | 17 |
|
@@ -129,7 +119,8 @@ def test_namespace_with_base(self): |
129 | 119 | assert len(f.must) == 2 |
130 | 120 | # One element must be the namespace FieldCondition |
131 | 121 | ns_items = [ |
132 | | - c for c in f.must |
| 122 | + c |
| 123 | + for c in f.must |
133 | 124 | if isinstance(c, models.FieldCondition) and c.key == "namespace" |
134 | 125 | ] |
135 | 126 | assert len(ns_items) == 1 |
@@ -177,7 +168,9 @@ def test_creates_payload_index_for_namespace(self): |
177 | 168 | class TestAdd: |
178 | 169 | def test_add_writes_points(self): |
179 | 170 | idx = make_index() |
180 | | - idx.add(embeddings=rand_vecs(2), routes=["r1", "r1"], utterances=["hello", "hi"]) |
| 171 | + idx.add( |
| 172 | + embeddings=rand_vecs(2), routes=["r1", "r1"], utterances=["hello", "hi"] |
| 173 | + ) |
181 | 174 | assert len(idx.get_utterances()) == 2 |
182 | 175 |
|
183 | 176 | def test_add_injects_namespace_payload(self): |
|
0 commit comments