mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 06:44:59 +00:00
add test for hash filenames
This commit is contained in:
parent
54cfbc4142
commit
cee0bb7135
1 changed files with 38 additions and 0 deletions
|
@ -246,6 +246,44 @@ after b
|
||||||
self.assertEqual(fname_a.read_text(), "after a\n")
|
self.assertEqual(fname_a.read_text(), "after a\n")
|
||||||
self.assertEqual(fname_b.read_text(), "after b\n")
|
self.assertEqual(fname_b.read_text(), "after b\n")
|
||||||
|
|
||||||
|
def test_update_hash_filename(self):
|
||||||
|
fname_a = Path("a.txt")
|
||||||
|
fname_b = Path("b.txt")
|
||||||
|
|
||||||
|
fname_a.write_text("before a\n")
|
||||||
|
fname_b.write_text("before b\n")
|
||||||
|
|
||||||
|
response = """
|
||||||
|
|
||||||
|
### a.txt
|
||||||
|
```
|
||||||
|
after a
|
||||||
|
```
|
||||||
|
|
||||||
|
### b.txt
|
||||||
|
```
|
||||||
|
after b
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
# Initialize WholeFileCoder with the temporary directory
|
||||||
|
io = InputOutput(yes=True)
|
||||||
|
coder = WholeFileCoder(main_model=self.GPT35, io=io, fnames=[fname_a, fname_b])
|
||||||
|
|
||||||
|
# Set the partial response content with the updated content
|
||||||
|
coder.partial_response_content = response
|
||||||
|
|
||||||
|
# Call update_files method
|
||||||
|
edited_files = coder.apply_updates()
|
||||||
|
|
||||||
|
dump(edited_files)
|
||||||
|
|
||||||
|
# Check if the sample file was updated
|
||||||
|
self.assertIn(str(fname_a), edited_files)
|
||||||
|
self.assertIn(str(fname_b), edited_files)
|
||||||
|
|
||||||
|
self.assertEqual(fname_a.read_text(), "after a\n")
|
||||||
|
self.assertEqual(fname_b.read_text(), "after b\n")
|
||||||
|
|
||||||
def test_update_named_file_but_extra_unnamed_code_block(self):
|
def test_update_named_file_but_extra_unnamed_code_block(self):
|
||||||
sample_file = "hello.py"
|
sample_file = "hello.py"
|
||||||
new_content = "new\ncontent\ngoes\nhere\n"
|
new_content = "new\ncontent\ngoes\nhere\n"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue