mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
improved tests
This commit is contained in:
parent
17c275b987
commit
14d19e22b2
1 changed files with 32 additions and 0 deletions
|
@ -62,6 +62,11 @@ class TestCoder(unittest.TestCase):
|
|||
self.assertTrue(coder.allowed_to_edit("repo.txt"))
|
||||
self.assertTrue(coder.allowed_to_edit("new.txt"))
|
||||
|
||||
self.assertIn("repo.txt", str(coder.abs_fnames))
|
||||
self.assertIn("new.txt", str(coder.abs_fnames))
|
||||
|
||||
self.assertFalse(coder.need_commit_before_edits)
|
||||
|
||||
def test_allowed_to_edit_no(self):
|
||||
with GitTemporaryDirectory():
|
||||
repo = git.Repo()
|
||||
|
@ -85,6 +90,33 @@ class TestCoder(unittest.TestCase):
|
|||
self.assertFalse(coder.allowed_to_edit("repo.txt"))
|
||||
self.assertFalse(coder.allowed_to_edit("new.txt"))
|
||||
|
||||
self.assertNotIn("repo.txt", str(coder.abs_fnames))
|
||||
self.assertNotIn("new.txt", str(coder.abs_fnames))
|
||||
|
||||
self.assertFalse(coder.need_commit_before_edits)
|
||||
|
||||
def test_allowed_to_edit_dirty(self):
|
||||
with GitTemporaryDirectory():
|
||||
repo = git.Repo()
|
||||
|
||||
fname = Path("added.txt")
|
||||
fname.touch()
|
||||
repo.git.add(str(fname))
|
||||
|
||||
repo.git.commit("-m", "init")
|
||||
|
||||
# say NO
|
||||
io = InputOutput(yes=False)
|
||||
|
||||
coder = Coder.create(models.GPT4, None, io, fnames=["added.txt"])
|
||||
|
||||
self.assertTrue(coder.allowed_to_edit("added.txt"))
|
||||
self.assertFalse(coder.need_commit_before_edits)
|
||||
|
||||
fname.write_text("dirty!")
|
||||
self.assertTrue(coder.allowed_to_edit("added.txt"))
|
||||
self.assertTrue(coder.need_commit_before_edits)
|
||||
|
||||
def test_get_last_modified(self):
|
||||
# Mock the IO object
|
||||
mock_io = MagicMock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue