Commit graph

9 commits

Author SHA1 Message Date
Paul Gauthier
d4d327e6d9 added test for non-backtick fences 2023-06-25 20:47:17 -07:00
Paul Gauthier
52343b5340 More generic handling of GPT mangling of filenames 2023-06-25 19:40:12 -07:00
Paul Gauthier
ac560c2877 Handle missing filenames by scanning for mentions in the text 2023-06-24 15:32:35 -07:00
Paul Gauthier
f2a03e917d Handle missing filename when only 1 in session 2023-06-24 15:13:39 -07:00
Paul Gauthier
eaf02da46b stronger wholefile prompt about file listings; adopt allowed_to_edit in wholefile; tests 2023-06-24 14:45:43 -07:00
Paul Gauthier
d00e7c39d1 working test 2023-06-24 14:37:25 -07:00
Paul Gauthier
b4f78547bc aider: Added setUp and tearDown methods to TestWholeFileCoder class to store and change the working directory back to the original one.
# Context:
USER: add setup and teardown which getcwd and chdir back
ASSISTANT: I will add `setUp` and `tearDown` methods to the `TestWholeFileCoder` class in the `tests/test_wholefile.py` file. The `setUp` method will store the current working directory, and the `tearDown` method will change the working directory back to the original one.

```python
tests/test_wholefile.py
<<<<<<< ORIGINAL
class TestWholeFileCoder(unittest.TestCase):
    def test_update_files(self):
=======
class TestWholeFileCoder(unittest.TestCase):
    def setUp(self):
        self.original_cwd = os.getcwd()

    def tearDown(self):
        os.chdir(self.original_cwd)

    def test_update_files(self):
>>>>>>> UPDATED
```

Let me know if you need any further changes.
2023-06-24 14:35:07 -07:00
Paul Gauthier
b4a92e312a aider: Added a test function to test the WholeFileCoder's update_files method.
# Context:
USER: make a test for `WholeFileCoder`.updated_files
ASSISTANT: To create a test for the `WholeFileCoder`'s `update_files` method, we will add a new test function in the `tests/test_wholefile.py` file. Here's the test function:

```python
tests/test_wholefile.py
<<<<<<< ORIGINAL

=======
import os
from pathlib import Path
import tempfile
import unittest

from aider.coders.wholefile_coder import WholeFileCoder
from aider.io import InputOutput

class TestWholeFileCoder(unittest.TestCase):
    def test_update_files(self):
        with tempfile.TemporaryDirectory() as temp_dir:
            # Create a sample file in the temporary directory
            sample_file = os.path.join(temp_dir, "sample.txt")
            with open(sample_file, "w") as f:
                f.write("Original content\n")

            # Initialize WholeFileCoder with the temporary directory
            io = InputOutput()
            coder = WholeFileCoder(root=temp_dir, io=io)

            # Set the partial response content with the updated content
            coder.partial_response_content = f"{sample_file}\n```\nUpdated content\n```"

            # Call update_files method
            edited_files = coder.update_files()

            # Check if the sample file was updated
            self.assertIn("sample.txt", edited_files)

            # Check if the content of the sample file was updated
            with open(sample_file, "r") as f:
                updated_content = f.read()
            self.assertEqual(updated_content, "Updated content\n")

if __name__ == "__main__":
    unittest.main()
>>>>>>> UPDATED
```

This test function creates a temporary directory with a sample file, initializes a `WholeFileCoder` instance with the temporary directory, sets the partial response content with the updated content, calls the `update_files` method, and checks if the sample file was updated correctly.
2023-06-24 14:33:20 -07:00
Paul Gauthier
b0d72cf296 Added new files to the git repo: tests/test_wholefile.py 2023-06-24 14:32:10 -07:00