Merge branch 'main' into indent-bad-edit

This commit is contained in:
Paul Gauthier 2023-08-08 12:43:57 -03:00
commit 77be993708
14 changed files with 150 additions and 49 deletions

View file

@ -22,6 +22,25 @@ 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())
# 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)}")
def test_allowed_to_edit(self):
with GitTemporaryDirectory():
repo = git.Repo(Path.cwd())

View file

@ -13,6 +13,19 @@ from tests.utils import GitTemporaryDirectory
class TestRepo(unittest.TestCase):
def test_diffs_empty_repo(self):
with GitTemporaryDirectory():
repo = git.Repo()
fname = Path("foo.txt")
fname.touch()
repo.git.add(str(fname))
git_repo = GitRepo(InputOutput(), None, ".")
diffs = git_repo.get_diffs(False)
self.assertNotEqual(diffs, "")
self.assertIsNotNone(diffs)
@patch("aider.repo.simple_send_with_retries")
def test_get_commit_message(self, mock_send):
mock_send.return_value = "a good commit message"