mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
test dry run
This commit is contained in:
parent
7bbf0c0870
commit
7d3c40ea21
1 changed files with 44 additions and 1 deletions
|
@ -238,7 +238,7 @@ These changes replace the `subprocess.run` patches with `subprocess.check_output
|
|||
result = eb.replace_part_with_missing_leading_whitespace(whole, part, replace)
|
||||
self.assertEqual(result, expected_output)
|
||||
|
||||
def test_choose_fence(self):
|
||||
def test_full_edit(self):
|
||||
# Create a few temporary files
|
||||
_, file1 = tempfile.mkstemp()
|
||||
|
||||
|
@ -274,6 +274,49 @@ new
|
|||
content = open(file1, encoding="utf-8").read()
|
||||
self.assertEqual(content, "one\nnew\nthree\n")
|
||||
|
||||
def test_full_edit_dry_run(self):
|
||||
# Create a few temporary files
|
||||
_, file1 = tempfile.mkstemp()
|
||||
|
||||
orig_content = "one\ntwo\nthree\n"
|
||||
|
||||
with open(file1, "w", encoding="utf-8") as f:
|
||||
f.write(orig_content)
|
||||
|
||||
files = [file1]
|
||||
|
||||
# Initialize the Coder object with the mocked IO and mocked repo
|
||||
coder = Coder.create(
|
||||
models.GPT4,
|
||||
"diff",
|
||||
io=InputOutput(dry_run=True),
|
||||
openai_api_key="fake_key",
|
||||
fnames=files,
|
||||
dry_run=True,
|
||||
)
|
||||
|
||||
def mock_send(*args, **kwargs):
|
||||
coder.partial_response_content = f"""
|
||||
Do this:
|
||||
|
||||
{Path(file1).name}
|
||||
<<<<<<< ORIGINAL
|
||||
two
|
||||
=======
|
||||
new
|
||||
>>>>>>> UPDATED
|
||||
|
||||
"""
|
||||
coder.partial_response_function_call = dict()
|
||||
|
||||
coder.send = MagicMock(side_effect=mock_send)
|
||||
|
||||
# Call the run method with a message
|
||||
coder.run(with_message="hi")
|
||||
|
||||
content = open(file1, encoding="utf-8").read()
|
||||
self.assertEqual(content, orig_content)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue