mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
test: refactor shell command suggestion test in test_coder.py
This commit is contained in:
parent
9125bfc441
commit
ac9aaff3cf
1 changed files with 4 additions and 7 deletions
|
@ -750,7 +750,7 @@ two
|
|||
def test_suggest_shell_commands(self):
|
||||
with GitTemporaryDirectory():
|
||||
io = InputOutput(yes=True)
|
||||
coder = Coder.create(self.GPT35, None, io=io)
|
||||
coder = Coder.create(self.GPT35, "diff", io=io)
|
||||
|
||||
def mock_send(*args, **kwargs):
|
||||
coder.partial_response_content = """Here's a shell command to run:
|
||||
|
@ -765,6 +765,9 @@ This command will print 'Hello, World!' to the console."""
|
|||
|
||||
coder.send = mock_send
|
||||
|
||||
# Mock the handle_shell_commands method to check if it's called
|
||||
coder.handle_shell_commands = MagicMock()
|
||||
|
||||
# Run the coder with a message
|
||||
coder.run(with_message="Suggest a shell command")
|
||||
|
||||
|
@ -772,12 +775,6 @@ This command will print 'Hello, World!' to the console."""
|
|||
self.assertEqual(len(coder.shell_commands), 1)
|
||||
self.assertEqual(coder.shell_commands[0], 'echo "Hello, World!"')
|
||||
|
||||
# Mock the handle_shell_commands method to check if it's called
|
||||
coder.handle_shell_commands = MagicMock()
|
||||
|
||||
# Run the coder again to trigger the shell command execution
|
||||
coder.run(with_message="Run the suggested command")
|
||||
|
||||
# Check if handle_shell_commands was called with the correct argument
|
||||
coder.handle_shell_commands.assert_called_once_with('echo "Hello, World!"', ANY)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue