mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-21 04:44:59 +00:00
aider: Updated test_send_with_retries tests to use backoff library instead of time.sleep.
# Context: USER: `tests/test_coder.py` `aider/coder.py` Fix the test_send_with_retries tests since we no longer use time.sleep but backoff instead ASSISTANT: To fix the test_send_with_retries tests in `tests/test_coder.py`, we need to update the tests to use the backoff library instead of time.sleep. Here's how to do it: 1. Replace the `@patch("aider.coder.time.sleep")` with `@patch("aider.coder.backoff.expo")` in both test_send_with_retries_rate_limit_error and test_send_with_retries_connection_error tests. 2. Update the test_send_with_retries_rate_limit_error and test_send_with_retries_connection_error tests to assert that backoff.expo was called once instead of time.sleep. Here are the changes: ```python tests/test_coder.py <<<<<<< ORIGINAL @patch("aider.coder.time.sleep") def test_send_with_retries_rate_limit_error(self, mock_sleep, mock_chat_completion_create): ======= @patch("aider.coder.backoff.expo") def test_send_with_retries_rate_limit_error(self, mock_backoff_expo, mock_chat_completion_create): >>>>>>> UPDATED ``` ```python tests/test_coder.py <<<<<<< ORIGINAL # Assert that time.sleep was called once mock_sleep.assert_called_once() ======= # Assert that backoff.expo was called once mock_backoff_expo.assert_called_once() >>>>>>> UPDATED ``` ```python tests/test_coder.py <<<<<<< ORIGINAL @patch("aider.coder.time.sleep") def test_send_with_retries_connection_error(self, mock_sleep, mock_chat_completion_create): ======= @patch("aider.coder.backoff.expo") def test_send_with_retries_connection_error(self, mock_backoff_expo, mock_chat_completion_create): >>>>>>> UPDATED ``` ```python tests/test_coder.py <<<<<<< ORIGINAL # Assert that time.sleep was called once mock_sleep.assert_called_once() ======= # Assert that backoff.expo was called once mock_backoff_expo.assert_called_once() >>>>>>> UPDATED ``` These changes should fix the test_send_with_retries tests in `tests/test_coder.py`.
This commit is contained in:
parent
df91e9ab1c
commit
091bcaa1a2
1 changed files with 8 additions and 8 deletions
|
@ -121,8 +121,8 @@ class TestCoder(unittest.TestCase):
|
|||
self.assertEqual(result, 'a good "commit message"')
|
||||
|
||||
@patch("aider.coder.openai.ChatCompletion.create")
|
||||
@patch("aider.coder.time.sleep")
|
||||
def test_send_with_retries_rate_limit_error(self, mock_sleep, mock_chat_completion_create):
|
||||
@patch("aider.coder.backoff.expo")
|
||||
def test_send_with_retries_rate_limit_error(self, mock_backoff_expo, mock_chat_completion_create):
|
||||
# Mock the IO object
|
||||
mock_io = MagicMock()
|
||||
|
||||
|
@ -139,12 +139,12 @@ class TestCoder(unittest.TestCase):
|
|||
# Call the send_with_retries method
|
||||
coder.send_with_retries("model", ["message"])
|
||||
|
||||
# Assert that time.sleep was called once
|
||||
mock_sleep.assert_called_once()
|
||||
# Assert that backoff.expo was called once
|
||||
mock_backoff_expo.assert_called_once()
|
||||
|
||||
@patch("aider.coder.openai.ChatCompletion.create")
|
||||
@patch("aider.coder.time.sleep")
|
||||
def test_send_with_retries_connection_error(self, mock_sleep, mock_chat_completion_create):
|
||||
@patch("aider.coder.backoff.expo")
|
||||
def test_send_with_retries_connection_error(self, mock_backoff_expo, mock_chat_completion_create):
|
||||
# Mock the IO object
|
||||
mock_io = MagicMock()
|
||||
|
||||
|
@ -161,8 +161,8 @@ class TestCoder(unittest.TestCase):
|
|||
# Call the send_with_retries method
|
||||
coder.send_with_retries("model", ["message"])
|
||||
|
||||
# Assert that time.sleep was called once
|
||||
mock_sleep.assert_called_once()
|
||||
# Assert that backoff.expo was called once
|
||||
mock_backoff_expo.assert_called_once()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue