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

Function test_initialize_no_tools_warning

tests/chat/test_chat_context.py:710–745  ·  view source on GitHub ↗

Test initialize prints warning when no tools available.

(monkeypatch, capsys)

Source from the content-addressed store, hash-verified

708
709@pytest.mark.asyncio
710async def test_initialize_no_tools_warning(monkeypatch, capsys):
711 """Test initialize prints warning when no tools available."""
712 monkeypatch.setattr(
713 "mcp_cli.chat.chat_context.generate_system_prompt",
714 lambda tools=None, **kw: "SYS_PROMPT",
715 )
716
717 from unittest.mock import Mock
718 from mcp_cli.model_management import ModelManager
719
720 # Create tool manager that returns no tools
721 class EmptyToolManager:
722 async def get_unique_tools(self):
723 return []
724
725 async def get_server_info(self):
726 return []
727
728 async def get_adapted_tools_for_llm(self, provider):
729 return [], {}
730
731 async def get_tools_for_llm(self):
732 return []
733
734 mock_manager = Mock(spec=ModelManager)
735 mock_manager.get_client.return_value = None
736 mock_manager.get_active_provider.return_value = "mock"
737 mock_manager.get_active_model.return_value = "mock-model"
738
739 ctx = ChatContext.create(
740 tool_manager=EmptyToolManager(), model_manager=mock_manager
741 )
742 result = await ctx.initialize()
743
744 assert result is True
745 assert ctx.get_tool_count() == 0
746
747
748@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 4

EmptyToolManagerClass · 0.85
get_tool_countMethod · 0.80
createMethod · 0.45
initializeMethod · 0.45

Tested by

no test coverage detected