MCPcopy Create free account
hub / github.com/IBM/mcp-cli / test_inject_tool_message

Method test_inject_tool_message

tests/chat/test_chat_context.py:1387–1409  ·  view source on GitHub ↗

inject_tool_message stores a TOOL_CALL event.

(self, monkeypatch)

Source from the content-addressed store, hash-verified

1385
1386 @pytest.mark.asyncio
1387 async def test_inject_tool_message(self, monkeypatch):
1388 """inject_tool_message stores a TOOL_CALL event."""
1389 from chuk_ai_session_manager.models.event_type import EventType
1390 from mcp_cli.chat.models import HistoryMessage, MessageRole
1391
1392 ctx = _make_initialized_ctx(monkeypatch)
1393 ctx._system_prompt = "SYS"
1394 await ctx._initialize_session()
1395
1396 msg = HistoryMessage(
1397 role=MessageRole.TOOL,
1398 content="tool result here",
1399 tool_call_id="call-999",
1400 )
1401 ctx.inject_tool_message(msg)
1402
1403 events = ctx.session._session.events
1404 tool_events = [e for e in events if e.type == EventType.TOOL_CALL]
1405 assert len(tool_events) == 1
1406 # The stored message is the dict form
1407 stored = tool_events[0].message
1408 assert isinstance(stored, dict)
1409 assert stored.get("role") == "tool"
1410
1411 @pytest.mark.asyncio
1412 async def test_inject_tool_message_in_history(self, monkeypatch):

Callers

nothing calls this directly

Calls 5

HistoryMessageClass · 0.90
_make_initialized_ctxFunction · 0.85
_initialize_sessionMethod · 0.80
inject_tool_messageMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected