RandomZ / app /tests /test_qdrant_point_ids.py
StormShadow308's picture
feat: async pipeline, job queue, generation hardening, and docs
732b14f
Raw
History Blame Contribute Delete
1.18 kB
"""Qdrant stable point IDs and hybrid gating (Phase 1)."""
from __future__ import annotations
import uuid
from unittest.mock import MagicMock, patch
import pytest
from app.vectorstore.qdrant_wrapper import _stable_point_id
def test_stable_point_id_is_uuid_and_deterministic() -> None:
cid = "doc-1_hier_paragraph_3"
a = _stable_point_id(cid)
b = _stable_point_id(cid)
assert a == b
uuid.UUID(a)
assert _stable_point_id("other") != a
def test_hybrid_does_not_require_async_pipeline_flag(monkeypatch: pytest.MonkeyPatch) -> None:
from app.config import settings
from app.vectorstore.qdrant_wrapper import QdrantVectorStore
monkeypatch.setattr(settings, "enable_hybrid_retrieval", True, raising=False)
monkeypatch.setattr(settings, "enable_async_pipeline", False, raising=False)
monkeypatch.setattr(settings, "vectorstore_backend", "qdrant", raising=False)
vs = QdrantVectorStore.__new__(QdrantVectorStore)
vs._bm25_rows = {"t1": [MagicMock()]}
vs._bm25_texts = {"t1": ["text"]}
vs._ensure_bm25_for_tenant = MagicMock(return_value=True) # type: ignore[method-assign]
assert vs._want_hybrid("t1") is True