mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-21 04:44:59 +00:00
added import
This commit is contained in:
parent
2d1fc9f6da
commit
5263367af0
1 changed files with 8 additions and 3 deletions
|
@ -3,6 +3,7 @@ import unittest
|
|||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import openai
|
||||
import requests
|
||||
|
||||
from aider.coder import Coder
|
||||
|
||||
|
@ -141,7 +142,6 @@ class TestCoder(unittest.TestCase):
|
|||
# Assert that time.sleep was called once
|
||||
mock_sleep.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):
|
||||
|
@ -151,8 +151,12 @@ class TestCoder(unittest.TestCase):
|
|||
# Initialize the Coder object with the mocked IO and mocked repo
|
||||
coder = Coder(io=mock_io, openai_api_key="fake_key")
|
||||
|
||||
# Set up the mock to raise ConnectionError on the first call and return None on the second call
|
||||
mock_chat_completion_create.side_effect = [requests.exceptions.ConnectionError("Connection error"), None]
|
||||
# Set up the mock to raise ConnectionError on the first call
|
||||
# and return None on the second call
|
||||
mock_chat_completion_create.side_effect = [
|
||||
requests.exceptions.ConnectionError("Connection error"),
|
||||
None,
|
||||
]
|
||||
|
||||
# Call the send_with_retries method
|
||||
coder.send_with_retries("model", ["message"])
|
||||
|
@ -160,5 +164,6 @@ class TestCoder(unittest.TestCase):
|
|||
# Assert that time.sleep was called once
|
||||
mock_sleep.assert_called_once()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue