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

Method test_stdin_input

tests/commands/cmd/test_cmd_command.py:208–227  ·  view source on GitHub ↗

input_file='-' reads from sys.stdin and passes content to the LLM.

(self, cmd)

Source from the content-addressed store, hash-verified

206
207 @pytest.mark.asyncio
208 async def test_stdin_input(self, cmd):
209 """input_file='-' reads from sys.stdin and passes content to the LLM."""
210 ctx = _make_context()
211 mock_client = MagicMock()
212 mock_client.create_completion = AsyncMock(
213 return_value={"response": "got it", "tool_calls": []}
214 )
215 ctx.model_manager.get_client.return_value = mock_client
216
217 with patch(_GET_CONTEXT, return_value=ctx), \
218 patch("mcp_cli.commands.cmd.cmd.sys.stdin", new=io.StringIO("stdin data\n")), \
219 patch("builtins.print"):
220 result = await cmd.execute(
221 input_file="-", model_manager=ctx.model_manager
222 )
223
224 assert result.success is True
225 call_kwargs = mock_client.create_completion.call_args
226 messages = call_kwargs.kwargs.get("messages") or call_kwargs[1].get("messages")
227 assert "stdin data" in messages[-1]["content"]
228
229 @pytest.mark.asyncio
230 async def test_input_file_not_found(self, cmd):

Callers

nothing calls this directly

Calls 3

_make_contextFunction · 0.70
executeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected