mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 22:04:59 +00:00
Refactor test_get_commit_message_strip_quotes to use a mocked send_with_retries function and set the return value of the mocked function.
This commit is contained in:
parent
1733fe4c90
commit
b9dc419f19
1 changed files with 12 additions and 14 deletions
|
@ -33,22 +33,20 @@ class TestRepo(unittest.TestCase):
|
|||
# Assert that the returned message is the expected one
|
||||
self.assertEqual(result, "a good commit message")
|
||||
|
||||
def test_get_commit_message_strip_quotes(self):
|
||||
# Mock the IO object
|
||||
mock_io = MagicMock()
|
||||
|
||||
# Initialize the Coder object with the mocked IO and mocked repo
|
||||
coder = Coder.create(models.GPT4, None, mock_io)
|
||||
|
||||
# Mock the send method to set partial_response_content and return False
|
||||
def mock_send(*args, **kwargs):
|
||||
coder.partial_response_content = "a good commit message"
|
||||
return False
|
||||
|
||||
coder.send = MagicMock(side_effect=mock_send)
|
||||
@patch("aider.repo.send_with_retries")
|
||||
def test_get_commit_message_strip_quotes(self, mock_send):
|
||||
# Set the return value of the mocked function
|
||||
mock_response = MagicMock()
|
||||
mock_response.choices = [MagicMock()]
|
||||
mock_response.choices[0].message.content = '"a good commit message"'
|
||||
mock_send.return_value = (
|
||||
None,
|
||||
mock_response
|
||||
)
|
||||
|
||||
repo = AiderRepo(InputOutput(), None)
|
||||
# Call the get_commit_message method with dummy diff and context
|
||||
result = coder.get_commit_message("dummy diff", "dummy context")
|
||||
result = repo.get_commit_message("dummy diff", "dummy context")
|
||||
|
||||
# Assert that the returned message is the expected one
|
||||
self.assertEqual(result, "a good commit message")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue