inject_tool_message stores a TOOL_CALL event.
(self, monkeypatch)
| 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): |
nothing calls this directly
no test coverage detected