From 4956c358703669807d17ecc590d1e60af960c75a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 20 Jun 2023 17:16:06 -0700 Subject: [PATCH] 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. --- tests/test_coder.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_coder.py b/tests/test_coder.py index cfc45db20..4125ee373 100644 --- a/tests/test_coder.py +++ b/tests/test_coder.py @@ -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