File size: 1,177 Bytes
732b14f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""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