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

Method test_input_file_read

tests/commands/cmd/test_cmd_command.py:241–262  ·  view source on GitHub ↗
(self, cmd, tmp_path)

Source from the content-addressed store, hash-verified

239
240 @pytest.mark.asyncio
241 async def test_input_file_read(self, cmd, tmp_path):
242 input_file = tmp_path / "input.txt"
243 input_file.write_text("test data")
244
245 ctx = _make_context()
246 mock_client = MagicMock()
247 mock_client.create_completion = AsyncMock(
248 return_value={"response": "analyzed", "tool_calls": []}
249 )
250 ctx.model_manager.get_client.return_value = mock_client
251
252 with patch(_GET_CONTEXT, return_value=ctx):
253 with patch("builtins.print"):
254 result = await cmd.execute(
255 input_file=str(input_file),
256 model_manager=ctx.model_manager,
257 )
258 assert result.success is True
259 # Check that input text was used in the prompt
260 call_kwargs = mock_client.create_completion.call_args
261 messages = call_kwargs.kwargs.get("messages") or call_kwargs[1].get("messages")
262 assert "test data" in messages[-1]["content"]
263
264
265# ---------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 3

_make_contextFunction · 0.70
executeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected