Test async context manager.
(dummy_tool_manager, monkeypatch)
| 338 | |
| 339 | @pytest.mark.asyncio |
| 340 | async 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 |
nothing calls this directly
no test coverage detected