(self)
| 317 | self.assertEqual(updated_content, new_content) |
| 318 | |
| 319 | def test_full_edit(self): |
| 320 | # Create a few temporary files |
| 321 | _, file1 = tempfile.mkstemp() |
| 322 | |
| 323 | with open(file1, "w", encoding="utf-8") as f: |
| 324 | f.write("one\ntwo\nthree\n") |
| 325 | |
| 326 | files = [file1] |
| 327 | |
| 328 | # Initialize the Coder object with the mocked IO and mocked repo |
| 329 | coder = Coder.create(self.GPT35, "whole", io=InputOutput(), fnames=files, stream=False) |
| 330 | |
| 331 | # no trailing newline so the response content below doesn't add ANOTHER newline |
| 332 | new_content = "new\ntwo\nthree" |
| 333 | |
| 334 | def mock_send(*args, **kwargs): |
| 335 | coder.partial_response_content = f""" |
| 336 | Do this: |
| 337 | |
| 338 | {Path(file1).name} |
| 339 | ``` |
| 340 | {new_content} |
| 341 | ``` |
| 342 | |
| 343 | """ |
| 344 | coder.partial_response_function_call = dict() |
| 345 | return [] |
| 346 | |
| 347 | coder.send = MagicMock(side_effect=mock_send) |
| 348 | |
| 349 | # Call the run method with a message |
| 350 | coder.run(with_message="hi") |
| 351 | |
| 352 | content = Path(file1).read_text(encoding="utf-8") |
| 353 | |
| 354 | # check for one trailing newline |
| 355 | self.assertEqual(content, new_content + "\n") |
| 356 | |
| 357 | |
| 358 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected