mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-21 04:44:59 +00:00
Added test_check_for_ambiguous_filename_mentions_of_longer_paths
This commit is contained in:
parent
08164034ff
commit
4fd1bf7f21
2 changed files with 22 additions and 5 deletions
|
@ -352,8 +352,12 @@ class Coder:
|
|||
fname_to_rel_fnames[fname].append(rel_fname)
|
||||
|
||||
for fname, rel_fnames in fname_to_rel_fnames.items():
|
||||
if len(rel_fnames) == 1 and (fname in words or rel_fnames[0] in words):
|
||||
if len(rel_fnames) == 1 and fname in words:
|
||||
mentioned_rel_fnames.add(rel_fnames[0])
|
||||
else:
|
||||
for rel_fname in rel_fnames:
|
||||
if rel_fname in words:
|
||||
mentioned_rel_fnames.add(rel_fname)
|
||||
|
||||
if not mentioned_rel_fnames:
|
||||
return
|
||||
|
|
|
@ -8,8 +8,6 @@ class TestCoder(unittest.TestCase):
|
|||
def test_check_for_file_mentions(self):
|
||||
# Mock the IO object
|
||||
mock_io = MagicMock()
|
||||
mock_io.get_input.return_value = "Please check file1.txt and file2.py"
|
||||
mock_io.confirm_ask.return_value = True
|
||||
|
||||
# Initialize the Coder object with the mocked IO and mocked repo
|
||||
coder = Coder(io=mock_io, openai_api_key="fake_key")
|
||||
|
@ -29,8 +27,6 @@ class TestCoder(unittest.TestCase):
|
|||
def test_check_for_filename_mentions_of_longer_paths(self):
|
||||
# Mock the IO object
|
||||
mock_io = MagicMock()
|
||||
mock_io.get_input.return_value = "Please check file1.txt and file2.py"
|
||||
mock_io.confirm_ask.return_value = True
|
||||
|
||||
# Initialize the Coder object with the mocked IO and mocked repo
|
||||
coder = Coder(io=mock_io, openai_api_key="fake_key")
|
||||
|
@ -47,6 +43,23 @@ class TestCoder(unittest.TestCase):
|
|||
expected_files = {os.path.abspath("file1.txt"), os.path.abspath("file2.py")}
|
||||
self.assertEqual(coder.abs_fnames, expected_files)
|
||||
|
||||
def test_check_for_ambiguous_filename_mentions_of_longer_paths(self):
|
||||
# Mock the IO object
|
||||
mock_io = MagicMock()
|
||||
|
||||
# Initialize the Coder object with the mocked IO and mocked repo
|
||||
coder = Coder(io=mock_io, openai_api_key="fake_key")
|
||||
|
||||
# Mock the git repo
|
||||
mock_repo = MagicMock()
|
||||
mock_repo.git.ls_files.return_value = "./file1.txt\n./other/file1.txt"
|
||||
coder.repo = mock_repo
|
||||
|
||||
# Call the check_for_file_mentions method
|
||||
coder.check_for_file_mentions("Please check file1.txt!")
|
||||
|
||||
self.assertEqual(coder.abs_fnames, set())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue