mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
feat: add test for check_for_file_mentions with read-only file
This commit is contained in:
parent
cb24f8c6d4
commit
1cc6841bad
1 changed files with 24 additions and 0 deletions
|
@ -189,6 +189,30 @@ class TestCoder(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(coder.abs_fnames, set([str(fname.resolve())]))
|
self.assertEqual(coder.abs_fnames, set([str(fname.resolve())]))
|
||||||
|
|
||||||
|
def test_check_for_file_mentions_read_only(self):
|
||||||
|
with GitTemporaryDirectory():
|
||||||
|
io = InputOutput(pretty=False, yes=False) # Set yes=False to simulate user not confirming
|
||||||
|
coder = Coder.create(self.GPT35, None, io)
|
||||||
|
|
||||||
|
fname = Path("readonly_file.txt")
|
||||||
|
fname.touch()
|
||||||
|
|
||||||
|
coder.abs_read_only_fnames.add(str(fname.resolve()))
|
||||||
|
|
||||||
|
# Mock the get_tracked_files method
|
||||||
|
mock = MagicMock()
|
||||||
|
mock.return_value = set([str(fname)])
|
||||||
|
coder.repo.get_tracked_files = mock
|
||||||
|
|
||||||
|
# Call the check_for_file_mentions method
|
||||||
|
result = coder.check_for_file_mentions(f"Please check {fname}!")
|
||||||
|
|
||||||
|
# Assert that the method returns None (user not asked to add the file)
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
# Assert that abs_fnames is still empty (file not added)
|
||||||
|
self.assertEqual(coder.abs_fnames, set())
|
||||||
|
|
||||||
def test_check_for_subdir_mention(self):
|
def test_check_for_subdir_mention(self):
|
||||||
with GitTemporaryDirectory():
|
with GitTemporaryDirectory():
|
||||||
io = InputOutput(pretty=False, yes=True)
|
io = InputOutput(pretty=False, yes=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue