mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 20:35:00 +00:00
improved tests
This commit is contained in:
parent
fbc4a49c24
commit
17c275b987
1 changed files with 23 additions and 9 deletions
|
@ -42,33 +42,47 @@ class TestCoder(unittest.TestCase):
|
|||
|
||||
def test_allowed_to_edit(self):
|
||||
with GitTemporaryDirectory():
|
||||
repo = git.Repo(Path.cwd())
|
||||
fname = Path("foo.txt")
|
||||
repo = git.Repo()
|
||||
|
||||
fname = Path("added.txt")
|
||||
fname.touch()
|
||||
repo.git.add(str(fname))
|
||||
|
||||
fname = Path("repo.txt")
|
||||
fname.touch()
|
||||
repo.git.add(str(fname))
|
||||
|
||||
repo.git.commit("-m", "init")
|
||||
|
||||
# YES!
|
||||
io = InputOutput(yes=True)
|
||||
# Initialize the Coder object with the mocked IO and mocked repo
|
||||
coder = Coder.create(models.GPT4, None, io, fnames=["foo.txt"])
|
||||
coder = Coder.create(models.GPT4, None, io, fnames=["added.txt"])
|
||||
|
||||
self.assertTrue(coder.allowed_to_edit("foo.txt"))
|
||||
self.assertTrue(coder.allowed_to_edit("added.txt"))
|
||||
self.assertTrue(coder.allowed_to_edit("repo.txt"))
|
||||
self.assertTrue(coder.allowed_to_edit("new.txt"))
|
||||
|
||||
def test_allowed_to_edit_no(self):
|
||||
with GitTemporaryDirectory():
|
||||
repo = git.Repo(Path.cwd())
|
||||
fname = Path("foo.txt")
|
||||
repo = git.Repo()
|
||||
|
||||
fname = Path("added.txt")
|
||||
fname.touch()
|
||||
repo.git.add(str(fname))
|
||||
|
||||
fname = Path("repo.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=["foo.txt"])
|
||||
coder = Coder.create(models.GPT4, None, io, fnames=["added.txt"])
|
||||
|
||||
self.assertTrue(coder.allowed_to_edit("foo.txt"))
|
||||
self.assertTrue(coder.allowed_to_edit("added.txt"))
|
||||
self.assertFalse(coder.allowed_to_edit("repo.txt"))
|
||||
self.assertFalse(coder.allowed_to_edit("new.txt"))
|
||||
|
||||
def test_get_last_modified(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue