mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 20:35:00 +00:00
Add a test for get_commit_message
that initializes a GitRepo
with two models and ensures the commit message is correctly retrieved from the second model.
This commit is contained in:
parent
350d0c781a
commit
f04fb8d53a
1 changed files with 13 additions and 3 deletions
|
@ -107,14 +107,24 @@ class TestRepo(unittest.TestCase):
|
|||
|
||||
@patch("aider.repo.simple_send_with_retries")
|
||||
def test_get_commit_message(self, mock_send):
|
||||
mock_send.return_value = "a good commit message"
|
||||
mock_send.side_effect = ["", "a good commit message"]
|
||||
|
||||
repo = GitRepo(InputOutput(), None, None, models=[self.GPT35])
|
||||
model1 = Model("gpt-3.5-turbo")
|
||||
model2 = Model("gpt-4")
|
||||
repo = GitRepo(InputOutput(), None, None, models=[model1, model2])
|
||||
|
||||
# Call the get_commit_message method with dummy diff and context
|
||||
result = repo.get_commit_message("dummy diff", "dummy context")
|
||||
|
||||
# Assert that the returned message is the expected one
|
||||
# Assert that the returned message is the expected one from the second model
|
||||
self.assertEqual(result, "a good commit message")
|
||||
|
||||
# Check that simple_send_with_retries was called twice
|
||||
self.assertEqual(mock_send.call_count, 2)
|
||||
|
||||
# Check that it was called with the correct model names
|
||||
mock_send.assert_any_call(model1.name, mock_send.call_args[0][1])
|
||||
mock_send.assert_any_call(model2.name, mock_send.call_args[0][1])
|
||||
|
||||
@patch("aider.repo.simple_send_with_retries")
|
||||
def test_get_commit_message_strip_quotes(self, mock_send):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue