test(8241): the pointer test reuses the auto-inject menu harness instead of copying it
CI & Build / TypeScript typecheck (push) Successful in 36s
CI & Build / Plugin hooks (push) Successful in 20s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Python tests (push) Successful in 2m28s
CI & Build / integration (push) Successful in 2m16s
CI & Build / Build & push image (push) Successful in 20s
CI & Build / TypeScript typecheck (push) Successful in 36s
CI & Build / Plugin hooks (push) Successful in 20s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Python tests (push) Successful in 2m28s
CI & Build / integration (push) Successful in 2m16s
CI & Build / Build & push image (push) Successful in 20s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import pytest
|
|||||||
from grimoire.services import note_usage
|
from grimoire.services import note_usage
|
||||||
from grimoire.services import plugin_context as pc
|
from grimoire.services import plugin_context as pc
|
||||||
from tests.helpers import fake_note
|
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
|
# Six equally close notes: the menu shows its top three, and the rest are
|
||||||
# named in the pointer line.
|
# 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]:
|
async def _pointer(ledger: set[int]) -> tuple[list[int], MagicMock]:
|
||||||
"""The ids the auto-inject pointer line names, given what the session's
|
"""The ids the auto-inject pointer line names, given what the session's
|
||||||
delivery ledger already holds, and the booking call."""
|
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()
|
booked = MagicMock()
|
||||||
with patch.object(pc, "get_autoinject_config",
|
with patch.object(pc.record_deliveries_svc, "delivered_this_session",
|
||||||
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",
|
|
||||||
AsyncMock(return_value=set(ledger))), \
|
AsyncMock(return_value=set(ledger))), \
|
||||||
patch.object(pc.record_deliveries_svc, "record", booked):
|
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), "")
|
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
|
return [int(i) for i in re.findall(r"#(\d+)", line)], booked
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user