fix: close task3 qdrant and config validation gaps
This commit is contained in:
@@ -16,6 +16,17 @@ class _FakeEmbedder:
|
||||
return [[0.1] * 4 for _ in documents]
|
||||
|
||||
|
||||
class _Response:
|
||||
def __init__(self, status_code, payload=None):
|
||||
self.status_code = status_code
|
||||
self.ok = status_code < 400
|
||||
self._payload = payload
|
||||
self.text = "" if payload is None else "{}"
|
||||
|
||||
def json(self):
|
||||
return self._payload
|
||||
|
||||
|
||||
class _FakeVectorStore:
|
||||
def __init__(self):
|
||||
self.upserts = []
|
||||
@@ -218,6 +229,55 @@ def test_vector_index_schema_json_is_single_document(monkeypatch, tmp_path):
|
||||
assert payload["counts"]["added"] == 2
|
||||
|
||||
|
||||
def test_vector_index_schema_json_maps_initial_missing_collection(monkeypatch, tmp_path):
|
||||
cfg = _qdrant_runtime_config(tmp_path)
|
||||
_write_schema_artifacts(tmp_path)
|
||||
calls = []
|
||||
|
||||
def request(method, url, **kwargs):
|
||||
calls.append((method, url))
|
||||
if method == "GET" and url.endswith("/collections/psd-clinical"):
|
||||
return _Response(404, {"status": {"error": "missing"}})
|
||||
raise AssertionError((method, url))
|
||||
|
||||
monkeypatch.setattr("requests.request", request)
|
||||
response = CliRunner().invoke(app, ["vector", "index-schema", "--json", "-c", str(cfg)])
|
||||
|
||||
assert response.exit_code == 1
|
||||
assert response.stdout == '{"code":"semantic_index_incompatible","status":"failed"}\n'
|
||||
assert response.stderr == ""
|
||||
assert not [call for call in calls if call[0] == "PUT"]
|
||||
assert not [call for call in calls if call[1].endswith("/points/scroll")]
|
||||
|
||||
|
||||
def test_vector_index_schema_json_rejects_incompatible_empty_collection(monkeypatch, tmp_path):
|
||||
cfg = _qdrant_runtime_config(tmp_path)
|
||||
_write_schema_artifacts(tmp_path)
|
||||
keyword_indexes = {
|
||||
"content_hash", "document_id", "kind", "record_key", "record_kind",
|
||||
"vector_generation", "workspace_id", "workspace_revision",
|
||||
}
|
||||
calls = []
|
||||
|
||||
def request(method, url, **kwargs):
|
||||
calls.append((method, url))
|
||||
if method == "GET" and url.endswith("/collections/psd-clinical"):
|
||||
return _Response(200, {"result": {
|
||||
"config": {"params": {"vectors": {"size": 384, "distance": "Cosine"}}},
|
||||
"payload_schema": {key: {"data_type": "keyword"} for key in keyword_indexes},
|
||||
}})
|
||||
raise AssertionError((method, url))
|
||||
|
||||
monkeypatch.setattr("requests.request", request)
|
||||
response = CliRunner().invoke(app, ["vector", "index-schema", "--json", "-c", str(cfg)])
|
||||
|
||||
assert response.exit_code == 1
|
||||
assert response.stdout == '{"code":"semantic_index_incompatible","status":"failed"}\n'
|
||||
assert response.stderr == ""
|
||||
assert not [call for call in calls if call[0] == "PUT"]
|
||||
assert not [call for call in calls if call[1].endswith("/points/scroll")]
|
||||
|
||||
|
||||
def test_vector_index_schema_json_maps_require_existing_delete_race(monkeypatch, tmp_path):
|
||||
cfg = _qdrant_runtime_config(tmp_path)
|
||||
_write_schema_artifacts(tmp_path)
|
||||
|
||||
Reference in New Issue
Block a user