Pointers once a session; the code index knows what each test guards; a reviewing-tests skill #237
@@ -19,6 +19,7 @@ import pytest
|
||||
from grimoire.services import note_usage
|
||||
from grimoire.services import plugin_context as pc
|
||||
from tests.helpers import fake_note
|
||||
from tests.test_autoinject_context import _menu
|
||||
|
||||
# Six equally close notes: the menu shows its top three, and the rest are
|
||||
# named in the pointer line.
|
||||
@@ -29,24 +30,11 @@ HITS = [(0.8 - i * 0.001, fake_note(id=20 + i, title=f"a note {i}", note_type="n
|
||||
async def _pointer(ledger: set[int]) -> tuple[list[int], MagicMock]:
|
||||
"""The ids the auto-inject pointer line names, given what the session's
|
||||
delivery ledger already holds, and the booking call."""
|
||||
calls: list[int] = []
|
||||
|
||||
async def _search(*_a, **kw):
|
||||
calls.append(1)
|
||||
return HITS if len(calls) == 1 else []
|
||||
|
||||
booked = MagicMock()
|
||||
with patch.object(pc, "get_autoinject_config",
|
||||
AsyncMock(return_value={"enabled": True, "threshold": 0.55, "top_k": 3})), \
|
||||
patch.object(pc, "semantic_search_notes", _search), \
|
||||
patch.object(pc, "superseded_ids", AsyncMock(return_value=set())), \
|
||||
patch.object(pc, "system_names_for", AsyncMock(return_value={})), \
|
||||
patch.object(pc, "record_retrieval", MagicMock()), \
|
||||
patch.object(pc, "record_surfaced", MagicMock()), \
|
||||
patch.object(pc.record_deliveries_svc, "delivered_this_session",
|
||||
with patch.object(pc.record_deliveries_svc, "delivered_this_session",
|
||||
AsyncMock(return_value=set(ledger))), \
|
||||
patch.object(pc.record_deliveries_svc, "record", booked):
|
||||
out = (await pc.build_autoinject_hint(1, "q", project_id=2))["context"]
|
||||
out = await _menu(HITS, [], {})
|
||||
line = next((ln for ln in out.splitlines() if pc.POINTER_LEAD in ln), "")
|
||||
return [int(i) for i in re.findall(r"#(\d+)", line)], booked
|
||||
|
||||
|
||||
Reference in New Issue
Block a user