test: remove redundant co-authored-by precedence test

Co-authored-by: aider (vertex_ai/gemini-2.5-pro-exp-03-25) <noreply@aider.dev>
This commit is contained in:
Andrew Grigorev 2025-04-12 19:58:29 +03:00
parent 9e91e8f1b2
commit 6a970c3515

View file

@ -322,60 +322,6 @@ class TestRepo(unittest.TestCase):
self.assertEqual(commit.author.name, "Test User (aider)") # Should be modified
self.assertEqual(commit.committer.name, "Test User (aider)") # Should be modified
def test_commit_co_authored_by_precedence_over_default(self):
# Test that co-authored-by takes precedence over default (None) name modification
if platform.system() == "Windows":
return
with GitTemporaryDirectory():
# new repo
raw_repo = git.Repo()
raw_repo.config_writer().set_value("user", "name", "Test User").release()
raw_repo.config_writer().set_value("user", "email", "test@example.com").release()
# add a file and commit it
fname = Path("file.txt")
fname.touch()
raw_repo.git.add(str(fname))
raw_repo.git.commit("-m", "initial commit")
# Mock coder args: Co-authored-by enabled, author/committer use default (None)
mock_coder = MagicMock()
mock_coder.args.attribute_co_authored_by = True
mock_coder.args.attribute_author = None # Default
mock_coder.args.attribute_committer = None # Default
mock_coder.args.attribute_commit_message_author = False
mock_coder.args.attribute_commit_message_committer = False
mock_coder.main_model = MagicMock() # Define main_model before accessing name
mock_coder.main_model.name = "gpt-precedence"
io = InputOutput()
# Initialize GitRepo directly with flags, simulating config/defaults
# Use None for author/committer to test default behavior
git_repo = GitRepo(
io,
None,
None,
attribute_co_authored_by=True,
attribute_author=None, # Default
attribute_committer=None, # Default
)
# commit a change with aider_edits=True and default flags
fname.write_text("new content precedence")
# Pass the coder object here to ensure its args are used if available,
# but the GitRepo init already set the fallback values.
commit_result = git_repo.commit(fnames=[str(fname)], aider_edits=True, coder=mock_coder, message="Aider precedence edit")
self.assertIsNotNone(commit_result)
# check the commit message and author/committer
commit = raw_repo.head.commit
self.assertIn("Co-authored-by: aider (gpt-precedence) <noreply@aider.dev>", commit.message)
self.assertEqual(commit.message.splitlines()[0], "Aider precedence edit")
# Co-authored-by should take precedence over default (None), names should NOT be modified
self.assertEqual(commit.author.name, "Test User")
self.assertEqual(commit.committer.name, "Test User")
def test_commit_ai_edits_no_coauthor_explicit_false(self):
# Test AI edits (aider_edits=True) when co-authored-by is False,
# but author or committer attribution is explicitly disabled.