Merge pull request #378 from VariousForks/log_message_arg_patch_2023-11-27_unit_test

Fixes #374 - logging add_to_input_history if args.message is used. (and unit test)
This commit is contained in:
paul-gauthier 2023-12-05 13:19:44 -08:00 committed by GitHub
commit 93236e2e7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

@ -560,6 +560,7 @@ def main(argv=None, input=None, output=None, force_git_root=None):
io.tool_error(f"Git working dir: {git_root}")
if args.message:
io.add_to_input_history(args.message)
io.tool_output()
coder.run(with_message=args.message)
else:

View file

@ -196,3 +196,13 @@ class TestMain(TestCase):
MockSend.side_effect = side_effect
main(["--yes", fname, "--encoding", "iso-8859-15"])
@patch("aider.main.InputOutput")
@patch("openai.ChatCompletion.create")
def test_main_message_adds_to_input_history(self, mock_chat_completion, MockInputOutput):
test_message = "test message"
mock_io_instance = MockInputOutput.return_value
mock_chat_completion.return_value = MagicMock(choices=[{"text": "mocked response"}])
main(["--message", test_message], input=DummyInput(), output=DummyOutput())
mock_io_instance.add_to_input_history.assert_called_once_with(test_message)