fix: Use call_args_list to verify all calls to mocked function

This commit is contained in:
Paul Gauthier (aider) 2024-08-23 15:17:16 -07:00
parent 100cca5dbf
commit 427a83b075

View file

@ -125,11 +125,15 @@ class TestRepo(unittest.TestCase):
# Check that simple_send_with_retries was called twice
self.assertEqual(mock_send.call_count, 2)
dump(mock_send.call_args)
# Check that it was called with the correct model names
mock_send.assert_any_call(model1.name, mock_send.call_args[0][1])
mock_send.assert_any_call(model2.name, mock_send.call_args[0][1])
self.assertEqual(mock_send.call_args_list[0][0][0], model1.name)
self.assertEqual(mock_send.call_args_list[1][0][0], model2.name)
# Check that the content of the messages is the same for both calls
self.assertEqual(mock_send.call_args_list[0][0][1], mock_send.call_args_list[1][0][1])
# Optionally, you can still dump the call args if needed for debugging
dump(mock_send.call_args_list)
@patch("aider.repo.simple_send_with_retries")
def test_get_commit_message_strip_quotes(self, mock_send):