MCPcopy
hub / github.com/Aider-AI/aider / test_new_file_edit_one_commit

Method test_new_file_edit_one_commit

tests/basic/test_coder.py:570–610  ·  view source on GitHub ↗

A new file should get pre-committed before the GPT edit commit

(self)

Source from the content-addressed store, hash-verified

568 self.assertEqual(len(coder.abs_fnames), 2)
569
570 def test_new_file_edit_one_commit(self):
571 """A new file should get pre-committed before the GPT edit commit"""
572 with GitTemporaryDirectory():
573 repo = git.Repo()
574
575 fname = Path("file.txt")
576
577 io = InputOutput(yes=True)
578 coder = Coder.create(self.GPT35, "diff", io=io, fnames=[str(fname)])
579
580 self.assertTrue(fname.exists())
581
582 # make sure it was not committed
583 with self.assertRaises(git.exc.GitCommandError):
584 list(repo.iter_commits(repo.active_branch.name))
585
586 def mock_send(*args, **kwargs):
587 coder.partial_response_content = f"""
588Do this:
589
590{str(fname)}
591<<<<<<< SEARCH
592=======
593new
594>>>>>>> REPLACE
595
596"""
597 coder.partial_response_function_call = dict()
598 return []
599
600 coder.send = mock_send
601 coder.repo.get_commit_message = MagicMock()
602 coder.repo.get_commit_message.return_value = "commit message"
603
604 coder.run(with_message="hi")
605
606 content = fname.read_text()
607 self.assertEqual(content, "new\n")
608
609 num_commits = len(list(repo.iter_commits(repo.active_branch.name)))
610 self.assertEqual(num_commits, 2)
611
612 def test_only_commit_gpt_edited_file(self):
613 """

Callers

nothing calls this directly

Calls 5

InputOutputClass · 0.90
createMethod · 0.80
runMethod · 0.45
read_textMethod · 0.45

Tested by

no test coverage detected