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

Method test_happy_path

tests/chat/test_chat_handler_coverage.py:67–110  ·  view source on GitHub ↗

Normal execution returns True.

(self)

Source from the content-addressed store, hash-verified

65
66 @pytest.mark.asyncio
67 async def test_happy_path(self):
68 """Normal execution returns True."""
69 tool_mgr = MagicMock()
70 tool_mgr.close = AsyncMock()
71 tool_mgr.get_tool_count = MagicMock(return_value=5)
72
73 mock_ctx = _make_ctx()
74 mock_ctx.initialize = AsyncMock(return_value=True)
75
76 mock_app_ctx = MagicMock()
77 mock_app_ctx.model_manager = MagicMock()
78 mock_app_ctx.initialize = AsyncMock()
79
80 ui = _make_ui()
81 convo = _make_convo()
82
83 with (
84 patch("mcp_cli.chat.chat_handler.initialize_config"),
85 patch(
86 "mcp_cli.chat.chat_handler.initialize_context",
87 return_value=mock_app_ctx,
88 ),
89 patch("mcp_cli.chat.chat_handler.output") as mock_output,
90 patch("mcp_cli.chat.chat_handler.clear_screen"),
91 patch("mcp_cli.chat.chat_handler.display_chat_banner"),
92 patch("mcp_cli.chat.chat_handler.ChatContext") as MockCC,
93 patch("mcp_cli.chat.chat_handler.ChatUIManager", return_value=ui),
94 patch(
95 "mcp_cli.chat.chat_handler.ConversationProcessor", return_value=convo
96 ),
97 patch(
98 "mcp_cli.chat.chat_handler._run_enhanced_chat_loop",
99 new_callable=AsyncMock,
100 ),
101 patch("mcp_cli.chat.chat_handler._safe_cleanup", new_callable=AsyncMock),
102 ):
103 mock_output.loading.return_value.__enter__ = MagicMock(return_value=None)
104 mock_output.loading.return_value.__exit__ = MagicMock(return_value=False)
105 MockCC.create.return_value = mock_ctx
106
107 from mcp_cli.chat.chat_handler import handle_chat_mode
108
109 result = await handle_chat_mode(tool_mgr, provider="openai", model="gpt-4")
110 assert result is True
111
112 @pytest.mark.asyncio
113 async def test_ctx_init_fails(self):

Callers

nothing calls this directly

Calls 4

handle_chat_modeFunction · 0.90
_make_ctxFunction · 0.85
_make_convoFunction · 0.85
_make_uiFunction · 0.70

Tested by

no test coverage detected