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:

<source>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
</source>
This commit is contained in:
Paul Gauthier 2023-08-08 08:01:15 -03:00
parent 737c2e0b5f
commit 20c7eb549c

View file

@ -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):