stronger wholefile prompt about file listings; adopt allowed_to_edit in wholefile; tests

This commit is contained in:
Paul Gauthier 2023-06-24 14:45:43 -07:00
parent d00e7c39d1
commit eaf02da46b
4 changed files with 50 additions and 12 deletions

View file

@ -41,6 +41,33 @@ class TestWholeFileCoder(unittest.TestCase):
updated_content = f.read()
self.assertEqual(updated_content, "Updated content\n")
def test_update_files_not_in_chat(self):
with tempfile.TemporaryDirectory() as temp_dir:
os.chdir(temp_dir)
# Create a sample file in the temporary directory
sample_file = "sample.txt"
with open(sample_file, "w") as f:
f.write("Original content\n")
# Initialize WholeFileCoder with the temporary directory
io = InputOutput(yes=True)
coder = WholeFileCoder(main_model=models.GPT35, 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()