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

Function test_context_manager

tests/chat/test_chat_context.py:340–362  ·  view source on GitHub ↗

Test async context manager.

(dummy_tool_manager, monkeypatch)

Source from the content-addressed store, hash-verified

338
339@pytest.mark.asyncio
340async def test_context_manager(dummy_tool_manager, monkeypatch):
341 """Test async context manager."""
342 monkeypatch.setattr(
343 "mcp_cli.chat.chat_context.generate_system_prompt",
344 lambda tools=None, **kw: "SYS_PROMPT",
345 )
346
347 from unittest.mock import Mock
348 from mcp_cli.model_management import ModelManager
349
350 mock_model_manager = Mock(spec=ModelManager)
351 mock_model_manager.provider = "mock"
352 mock_model_manager.model = "mock-model"
353 mock_model_manager.get_client.return_value = None
354 mock_model_manager.get_active_provider.return_value = "mock"
355 mock_model_manager.get_active_model.return_value = "mock-model"
356
357 from mcp_cli.chat.chat_context import ChatContext
358
359 async with ChatContext.create(
360 tool_manager=dummy_tool_manager, model_manager=mock_model_manager
361 ) as ctx:
362 assert ctx.get_tool_count() == 2
363
364
365@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 2

get_tool_countMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected