mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 20:35:00 +00:00

# Context: USER: don't compare the result string. check that coder.abs_fnames now contains both files ASSISTANT: To update the test to check if `coder.abs_fnames` contains both files, modify the test as follows: ```python tests/test_coder.py <<<<<<< ORIGINAL # Check if the result is as expected self.assertEqual(result, "Added files: file1.txt, file2.py") ======= # Check if coder.abs_fnames contains both files expected_files = {os.path.abspath("file1.txt"), os.path.abspath("file2.py")} self.assertEqual(coder.abs_fnames, expected_files) >>>>>>> UPDATED ``` This change will ensure that the test checks if `coder.abs_fnames` contains both files instead of comparing the result string.
28 lines
1 KiB
Python
28 lines
1 KiB
Python
import unittest
|
|
from unittest.mock import MagicMock
|
|
from aider.coder import Coder
|
|
|
|
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")
|
|
|
|
# Mock the git repo
|
|
mock_repo = MagicMock()
|
|
mock_repo.git.ls_files.return_value = "file1.txt\nfile2.py"
|
|
coder.repo = mock_repo
|
|
|
|
# Call the check_for_file_mentions method
|
|
result = coder.check_for_file_mentions("Please check file1.txt and file2.py")
|
|
|
|
# Check if coder.abs_fnames contains both files
|
|
expected_files = {os.path.abspath("file1.txt"), os.path.abspath("file2.py")}
|
|
self.assertEqual(coder.abs_fnames, expected_files)
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|