Test ChatContext.create with model only.
(dummy_tool_manager, monkeypatch)
| 431 | |
| 432 | @pytest.mark.asyncio |
| 433 | async def test_create_with_model_only(dummy_tool_manager, monkeypatch): |
| 434 | """Test ChatContext.create with model only.""" |
| 435 | monkeypatch.setattr( |
| 436 | "mcp_cli.chat.chat_context.generate_system_prompt", |
| 437 | lambda tools=None, **kw: "SYS_PROMPT", |
| 438 | ) |
| 439 | |
| 440 | from unittest.mock import Mock |
| 441 | from mcp_cli.model_management import ModelManager |
| 442 | |
| 443 | mock_manager = Mock(spec=ModelManager) |
| 444 | mock_manager.get_client.return_value = None |
| 445 | mock_manager.get_active_provider.return_value = "openai" |
| 446 | mock_manager.get_active_model.return_value = "gpt-4" |
| 447 | mock_manager.switch_model.return_value = None |
| 448 | |
| 449 | with monkeypatch.context() as m: |
| 450 | m.setattr("mcp_cli.chat.chat_context.ModelManager", lambda: mock_manager) |
| 451 | ctx = ChatContext.create( |
| 452 | tool_manager=dummy_tool_manager, |
| 453 | model="gpt-4", |
| 454 | ) |
| 455 | assert ctx is not None |
| 456 | |
| 457 | |
| 458 | @pytest.mark.asyncio |