mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
fix: Simplify mocking in test_commands.py
This commit is contained in:
parent
91219eee30
commit
24f2741369
1 changed files with 4 additions and 6 deletions
|
@ -739,15 +739,13 @@ class TestCommands(TestCase):
|
||||||
question = "What is the meaning of life?"
|
question = "What is the meaning of life?"
|
||||||
canned_reply = "The meaning of life is 42."
|
canned_reply = "The meaning of life is 42."
|
||||||
|
|
||||||
with mock.patch("aider.coders.Coder.create") as mock_create:
|
with mock.patch("aider.coders.Coder.run") as mock_run:
|
||||||
mock_chat_coder = mock.MagicMock()
|
mock_run.return_value = canned_reply
|
||||||
mock_chat_coder.run.return_value = canned_reply
|
|
||||||
mock_create.return_value = mock_chat_coder
|
|
||||||
|
|
||||||
commands.cmd_ask(question)
|
commands.cmd_ask(question)
|
||||||
|
|
||||||
mock_create.assert_called_once()
|
mock_run.assert_called_once()
|
||||||
mock_chat_coder.run.assert_called_once_with(question)
|
mock_run.assert_called_once_with(question)
|
||||||
|
|
||||||
self.assertEqual(len(coder.cur_messages), 2)
|
self.assertEqual(len(coder.cur_messages), 2)
|
||||||
self.assertEqual(coder.cur_messages[0]["role"], "user")
|
self.assertEqual(coder.cur_messages[0]["role"], "user")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue