aider: Updated Coder to use the create class method in tests.

# Context:
USER: Coder has been changed to use the `create` class method. fix the tests to use this new method
ASSISTANT: I will update the tests in `tests/test_coder.py` to use the `create` class method.

```python
tests/test_coder.py
<<<<<<< ORIGINAL
        coder = Coder(io=mock_io, openai_api_key="fake_key")
=======
        coder = Coder.create(main_model=models.GPT4, io=mock_io, openai_api_key="fake_key")
>>>>>>> UPDATED
```

Please let me know if you need any further changes.
This commit is contained in:
Paul Gauthier 2023-06-20 17:16:06 -07:00
parent 0b45104da9
commit 4956c35870

View file

@ -22,7 +22,7 @@ class TestCoder(unittest.TestCase):
mock_io = MagicMock()
# Initialize the Coder object with the mocked IO and mocked repo
coder = Coder(io=mock_io, openai_api_key="fake_key")
coder = Coder.create(main_model=models.GPT4, io=mock_io, openai_api_key="fake_key")
# Mock the git repo
mock_repo = MagicMock()
@ -41,7 +41,7 @@ class TestCoder(unittest.TestCase):
mock_io = MagicMock()
# Initialize the Coder object with the mocked IO and mocked repo
coder = Coder(io=mock_io, openai_api_key="fake_key")
coder = Coder.create(main_model=models.GPT4, io=mock_io, openai_api_key="fake_key")
# Mock the git repo
mock_repo = MagicMock()
@ -60,7 +60,7 @@ class TestCoder(unittest.TestCase):
mock_io = MagicMock()
# Initialize the Coder object with the mocked IO and mocked repo
coder = Coder(io=mock_io, openai_api_key="fake_key")
coder = Coder.create(main_model=models.GPT4, io=mock_io, openai_api_key="fake_key")
# Mock the git repo
mock_repo = MagicMock()
@ -77,7 +77,7 @@ class TestCoder(unittest.TestCase):
mock_io = MagicMock()
# Initialize the Coder object with the mocked IO and mocked repo
coder = Coder(io=mock_io, openai_api_key="fake_key")
coder = Coder.create(main_model=models.GPT4, io=mock_io, openai_api_key="fake_key")
# Mock the send method to return a tuple with a message and False
coder.send = MagicMock(return_value=("a good commit message", False))
@ -93,7 +93,7 @@ class TestCoder(unittest.TestCase):
mock_io = MagicMock()
# Initialize the Coder object with the mocked IO and mocked repo
coder = Coder(io=mock_io, openai_api_key="fake_key")
coder = Coder.create(main_model=models.GPT4, io=mock_io, openai_api_key="fake_key")
# Mock the send method to return a tuple with a message and False
coder.send = MagicMock(return_value=('"a good commit message"', False))
@ -109,7 +109,7 @@ class TestCoder(unittest.TestCase):
mock_io = MagicMock()
# Initialize the Coder object with the mocked IO and mocked repo
coder = Coder(io=mock_io, openai_api_key="fake_key")
coder = Coder.create(main_model=models.GPT4, io=mock_io, openai_api_key="fake_key")
# Mock the send method to return a tuple with a message and False
coder.send = MagicMock(return_value=('a good "commit message"', False))
@ -127,7 +127,7 @@ class TestCoder(unittest.TestCase):
mock_io = MagicMock()
# Initialize the Coder object with the mocked IO and mocked repo
coder = Coder(io=mock_io, openai_api_key="fake_key")
coder = Coder.create(main_model=models.GPT4, io=mock_io, openai_api_key="fake_key")
# Set up the mock to raise RateLimitError on
# the first call and return None on the second call
@ -149,7 +149,7 @@ class TestCoder(unittest.TestCase):
mock_io = MagicMock()
# Initialize the Coder object with the mocked IO and mocked repo
coder = Coder(io=mock_io, openai_api_key="fake_key")
coder = Coder.create(main_model=models.GPT4, 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