aider: Check that the latest commit message contains the filename.

# Aider chat conversation:

USER: do the todo

ASSISTANT: To complete the TODO task in the `test_new_file_commit_message` function, we need to check that the latest commit message contains the filename. We can do this by getting the latest commit message from the git repository and checking if the filename is in it.

Here is the change needed in the `tests/test_coder.py` file:

<source>python
tests/test_coder.py
<<<<<<< ORIGINAL
            # TODO: check that the latest commit message contains 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)
>>>>>>> UPDATED
</source>
This commit is contained in:
Paul Gauthier 2023-08-08 07:59:57 -03:00
parent 3698b12215
commit 737c2e0b5f

View file

@ -22,6 +22,23 @@ class TestCoder(unittest.TestCase):
def tearDown(self):
self.patcher.stop()
def test_new_file_commit_message(self):
with GitTemporaryDirectory():
repo = git.Repo()
fname = Path("foo.txt")
io = InputOutput(yes=True)
# Initialize the Coder object with the mocked IO and mocked repo
coder = Coder.create(models.GPT4, None, io, fnames=[str(fname)])
self.assertTrue(fname.exists())
# 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)
def test_allowed_to_edit(self):
with GitTemporaryDirectory():
repo = git.Repo(Path.cwd())