mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
aider: The test case has been modified to add files to the directory and ensure they are added correctly.
# Aider chat conversation: USER: put some files in the test_dir, and the test shouldn't look for the exception. it should make sure the files were added ASSISTANT: To modify the test case to add files to the directory and ensure they are added correctly, we need to modify the `tests/test_commands.py` file. Here is the proposed change: ```python tests/test_commands.py <<<<<<< ORIGINAL def test_cmd_add_directory(self): # Initialize the Commands and InputOutput objects io = InputOutput(pretty=False, yes=True) from aider.coders import Coder coder = Coder.create(models.GPT35, None, io, openai_api_key="deadbeef") commands = Commands(io, coder) # Create a directory os.mkdir("test_dir") # Call the cmd_add method with a directory with self.assertRaises(IsADirectoryError): commands.cmd_add("test_dir") ======= def test_cmd_add_directory(self): # Initialize the Commands and InputOutput objects io = InputOutput(pretty=False, yes=True) from aider.coders import Coder coder = Coder.create(models.GPT35, None, io, openai_api_key="deadbeef") commands = Commands(io, coder) # Create a directory and add files to it os.mkdir("test_dir") with open("test_dir/test_file1.txt", "w") as f: f.write("Test file 1") with open("test_dir/test_file2.txt", "w") as f: f.write("Test file 2") # Call the cmd_add method with a directory commands.cmd_add("test_dir") # Check if the files have been added to the chat session self.assertIn(str(Path("test_dir/test_file1.txt").resolve()), coder.abs_fnames) self.assertIn(str(Path("test_dir/test_file2.txt").resolve()), coder.abs_fnames) >>>>>>> UPDATED ``` This new test case `test_cmd_add_directory` creates a directory named `test_dir`, adds two files to it, and attempts to add the directory using the `cmd_add` method. We then check if the files in the directory have been added to the chat session.
This commit is contained in:
parent
8be2f8086c
commit
4b91adabdc
1 changed files with 10 additions and 3 deletions
|
@ -87,13 +87,20 @@ class TestCommands(TestCase):
|
|||
coder = Coder.create(models.GPT35, None, io, openai_api_key="deadbeef")
|
||||
commands = Commands(io, coder)
|
||||
|
||||
# Create a directory
|
||||
# Create a directory and add files to it
|
||||
os.mkdir("test_dir")
|
||||
with open("test_dir/test_file1.txt", "w") as f:
|
||||
f.write("Test file 1")
|
||||
with open("test_dir/test_file2.txt", "w") as f:
|
||||
f.write("Test file 2")
|
||||
|
||||
# Call the cmd_add method with a directory
|
||||
with self.assertRaises(IsADirectoryError):
|
||||
commands.cmd_add("test_dir")
|
||||
|
||||
# Check if the files have been added to the chat session
|
||||
self.assertIn(str(Path("test_dir/test_file1.txt").resolve()), coder.abs_fnames)
|
||||
self.assertIn(str(Path("test_dir/test_file2.txt").resolve()), coder.abs_fnames)
|
||||
|
||||
def test_cmd_drop_with_glob_patterns(self):
|
||||
# Initialize the Commands and InputOutput objects
|
||||
io = InputOutput(pretty=False, yes=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue