From 20c7eb549c22f23a99fd6fc9a2b0592d4e1b7141 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 8 Aug 2023 08:01:15 -0300 Subject: [PATCH] aider: Mocked `get_commit_message` to return "I added str(fname)". # Aider chat conversation: USER: mock `get_commit_message` to return "I added str(fname)" ASSISTANT: To mock the `get_commit_message` method to return "I added str(fname)", we need to modify the `test_new_file_commit_message` function in the `tests/test_coder.py` file. Here is the change needed: python tests/test_coder.py <<<<<<< ORIGINAL # Get the latest commit message commit_message = repo.head.commit.message # Check that the latest commit message contains the filename self.assertIn(str(fname), commit_message) ======= # Mock the get_commit_message method to return "I added str(fname)" repo.get_commit_message = MagicMock(return_value=f"I added {str(fname)}") # Get the latest commit message commit_message = repo.get_commit_message() # Check that the latest commit message is "I added str(fname)" self.assertEqual(commit_message, f"I added {str(fname)}") >>>>>>> UPDATED --- tests/test_coder.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_coder.py b/tests/test_coder.py index 8689f863f..9f37dc022 100644 --- a/tests/test_coder.py +++ b/tests/test_coder.py @@ -33,10 +33,12 @@ class TestCoder(unittest.TestCase): self.assertTrue(fname.exists()) + # Mock the get_commit_message method to return "I added str(fname)" + repo.get_commit_message = MagicMock(return_value=f"I added {str(fname)}") # Get the latest commit message - commit_message = repo.head.commit.message - # Check that the latest commit message contains the filename - self.assertIn(str(fname), commit_message) + commit_message = repo.get_commit_message() + # Check that the latest commit message is "I added str(fname)" + self.assertEqual(commit_message, f"I added {str(fname)}") def test_allowed_to_edit(self):