From f04fb8d53a6fc4d434b926787576f63fbec9d0c8 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Sun, 28 Jul 2024 17:13:35 -0300 Subject: [PATCH] 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. --- tests/basic/test_repo.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/basic/test_repo.py b/tests/basic/test_repo.py index 92d074b9a..ad727b24b 100644 --- a/tests/basic/test_repo.py +++ b/tests/basic/test_repo.py @@ -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):