added import

This commit is contained in:
Paul Gauthier 2023-06-03 06:23:07 -07:00
parent 2d1fc9f6da
commit 5263367af0

View file

@ -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()