From d7ba886e6616c93449fa2da88cac9d3cbace2684 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 11 Jul 2023 07:32:31 -0700 Subject: [PATCH] added test_update_files_live_diff --- tests/test_wholefile.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_wholefile.py b/tests/test_wholefile.py index bd5a53139..83744c885 100644 --- a/tests/test_wholefile.py +++ b/tests/test_wholefile.py @@ -8,6 +8,7 @@ from unittest.mock import MagicMock, patch from aider import models from aider.coders import Coder from aider.coders.wholefile_coder import WholeFileCoder +from aider.dump import dump # noqa: F401 from aider.io import InputOutput @@ -76,6 +77,24 @@ class TestWholeFileCoder(unittest.TestCase): updated_content = f.read() self.assertEqual(updated_content, "Updated content\n") + def test_update_files_live_diff(self): + # Create a sample file in the temporary directory + sample_file = "sample.txt" + with open(sample_file, "w") as f: + f.write("\n".join(map(str, range(0, 100)))) + + # Initialize WholeFileCoder with the temporary directory + io = InputOutput(yes=True) + coder = WholeFileCoder(main_model=models.GPT35, io=io, fnames=[sample_file]) + + # Set the partial response content with the updated content + coder.partial_response_content = f"{sample_file}\n```\n0\n\1\n2\n" + + lines = coder.update_files(mode="diff").splitlines() + + # the live diff should be concise, since we haven't changed anything yet + self.assertLess(len(lines), 20) + def test_update_files_with_existing_fence(self): # Create a sample file in the temporary directory sample_file = "sample.txt"