MCPcopy
hub / github.com/Aider-AI/aider / test_cmd_copy

Method test_cmd_copy

tests/basic/test_commands.py:50–78  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

48 self.assertTrue(os.path.exists("bar.txt"))
49
50 def test_cmd_copy(self):
51 # Initialize InputOutput and Coder instances
52 io = InputOutput(pretty=False, fancy_input=False, yes=True)
53 coder = Coder.create(self.GPT35, None, io)
54 commands = Commands(io, coder)
55
56 # Add some assistant messages to the chat history
57 coder.done_messages = [
58 {"role": "assistant", "content": "First assistant message"},
59 {"role": "user", "content": "User message"},
60 {"role": "assistant", "content": "Second assistant message"},
61 ]
62
63 # Mock pyperclip.copy and io.tool_output
64 with (
65 mock.patch("pyperclip.copy") as mock_copy,
66 mock.patch.object(io, "tool_output") as mock_tool_output,
67 ):
68 # Invoke the /copy command
69 commands.cmd_copy("")
70
71 # Assert pyperclip.copy was called with the last assistant message
72 mock_copy.assert_called_once_with("Second assistant message")
73
74 # Assert that tool_output was called with the expected preview
75 expected_preview = (
76 "Copied last assistant message to clipboard. Preview: Second assistant message"
77 )
78 mock_tool_output.assert_any_call(expected_preview)
79
80 def test_cmd_copy_with_cur_messages(self):
81 # Initialize InputOutput and Coder instances

Callers

nothing calls this directly

Calls 4

cmd_copyMethod · 0.95
InputOutputClass · 0.90
CommandsClass · 0.90
createMethod · 0.80

Tested by

no test coverage detected