mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
updated tests
This commit is contained in:
parent
d97707a5c0
commit
2190435780
1 changed files with 13 additions and 23 deletions
|
@ -28,7 +28,7 @@ class TestCoder(unittest.TestCase):
|
||||||
mock_io = MagicMock()
|
mock_io = MagicMock()
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(models.GPT4, None, mock_io, openai_api_key="fake_key")
|
coder = Coder.create(models.GPT4, None, mock_io)
|
||||||
|
|
||||||
# Mock the git repo
|
# Mock the git repo
|
||||||
mock = MagicMock()
|
mock = MagicMock()
|
||||||
|
@ -62,9 +62,7 @@ class TestCoder(unittest.TestCase):
|
||||||
files = [file1, file2]
|
files = [file1, file2]
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(
|
coder = Coder.create(models.GPT4, None, io=InputOutput(), fnames=files)
|
||||||
models.GPT4, None, io=InputOutput(), openai_api_key="fake_key", fnames=files
|
|
||||||
)
|
|
||||||
|
|
||||||
content = coder.get_files_content().splitlines()
|
content = coder.get_files_content().splitlines()
|
||||||
self.assertIn("file1.txt", content)
|
self.assertIn("file1.txt", content)
|
||||||
|
@ -75,7 +73,7 @@ class TestCoder(unittest.TestCase):
|
||||||
mock_io = MagicMock()
|
mock_io = MagicMock()
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(models.GPT4, None, mock_io, openai_api_key="fake_key")
|
coder = Coder.create(models.GPT4, None, mock_io)
|
||||||
|
|
||||||
mock = MagicMock()
|
mock = MagicMock()
|
||||||
mock.return_value = set(["file1.txt", "file2.py"])
|
mock.return_value = set(["file1.txt", "file2.py"])
|
||||||
|
@ -101,7 +99,7 @@ class TestCoder(unittest.TestCase):
|
||||||
mock_io = MagicMock()
|
mock_io = MagicMock()
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(models.GPT4, None, mock_io, openai_api_key="fake_key")
|
coder = Coder.create(models.GPT4, None, mock_io)
|
||||||
|
|
||||||
mock = MagicMock()
|
mock = MagicMock()
|
||||||
mock.return_value = set(["file1.txt", "other/file1.txt"])
|
mock.return_value = set(["file1.txt", "other/file1.txt"])
|
||||||
|
@ -117,7 +115,7 @@ class TestCoder(unittest.TestCase):
|
||||||
mock_io = MagicMock()
|
mock_io = MagicMock()
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(models.GPT4, None, mock_io, openai_api_key="fake_key")
|
coder = Coder.create(models.GPT4, None, mock_io)
|
||||||
|
|
||||||
# Mock the send method to set partial_response_content and return False
|
# Mock the send method to set partial_response_content and return False
|
||||||
def mock_send(*args, **kwargs):
|
def mock_send(*args, **kwargs):
|
||||||
|
@ -137,7 +135,7 @@ class TestCoder(unittest.TestCase):
|
||||||
mock_io = MagicMock()
|
mock_io = MagicMock()
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(models.GPT4, None, mock_io, openai_api_key="fake_key")
|
coder = Coder.create(models.GPT4, None, mock_io)
|
||||||
|
|
||||||
# Mock the send method to set partial_response_content and return False
|
# Mock the send method to set partial_response_content and return False
|
||||||
def mock_send(*args, **kwargs):
|
def mock_send(*args, **kwargs):
|
||||||
|
@ -157,7 +155,7 @@ class TestCoder(unittest.TestCase):
|
||||||
mock_io = MagicMock()
|
mock_io = MagicMock()
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(models.GPT4, None, mock_io, openai_api_key="fake_key")
|
coder = Coder.create(models.GPT4, None, mock_io)
|
||||||
|
|
||||||
# Mock the send method to set partial_response_content and return False
|
# Mock the send method to set partial_response_content and return False
|
||||||
def mock_send(*args, **kwargs):
|
def mock_send(*args, **kwargs):
|
||||||
|
@ -179,7 +177,7 @@ class TestCoder(unittest.TestCase):
|
||||||
mock_io = MagicMock()
|
mock_io = MagicMock()
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(models.GPT4, None, mock_io, openai_api_key="fake_key")
|
coder = Coder.create(models.GPT4, None, mock_io)
|
||||||
|
|
||||||
# Set up the mock to raise RateLimitError on
|
# Set up the mock to raise RateLimitError on
|
||||||
# the first call and return None on the second call
|
# the first call and return None on the second call
|
||||||
|
@ -201,7 +199,7 @@ class TestCoder(unittest.TestCase):
|
||||||
mock_io = MagicMock()
|
mock_io = MagicMock()
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(models.GPT4, None, mock_io, openai_api_key="fake_key")
|
coder = Coder.create(models.GPT4, None, mock_io)
|
||||||
|
|
||||||
# Set up the mock to raise ConnectionError on the first call
|
# Set up the mock to raise ConnectionError on the first call
|
||||||
# and return None on the second call
|
# and return None on the second call
|
||||||
|
@ -230,9 +228,7 @@ class TestCoder(unittest.TestCase):
|
||||||
files = [file1, file2]
|
files = [file1, file2]
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(
|
coder = Coder.create(models.GPT4, None, io=InputOutput(), fnames=files)
|
||||||
models.GPT4, None, io=InputOutput(), openai_api_key="fake_key", fnames=files
|
|
||||||
)
|
|
||||||
|
|
||||||
def mock_send(*args, **kwargs):
|
def mock_send(*args, **kwargs):
|
||||||
coder.partial_response_content = "ok"
|
coder.partial_response_content = "ok"
|
||||||
|
@ -258,9 +254,7 @@ class TestCoder(unittest.TestCase):
|
||||||
files = [file1, file2]
|
files = [file1, file2]
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(
|
coder = Coder.create(models.GPT4, None, io=InputOutput(), fnames=files)
|
||||||
models.GPT4, None, io=InputOutput(), openai_api_key="fake_key", fnames=files
|
|
||||||
)
|
|
||||||
|
|
||||||
def mock_send(*args, **kwargs):
|
def mock_send(*args, **kwargs):
|
||||||
coder.partial_response_content = "ok"
|
coder.partial_response_content = "ok"
|
||||||
|
@ -290,9 +284,7 @@ class TestCoder(unittest.TestCase):
|
||||||
files = [file1]
|
files = [file1]
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(
|
coder = Coder.create(models.GPT4, None, io=InputOutput(), fnames=files)
|
||||||
models.GPT4, None, io=InputOutput(), openai_api_key="fake_key", fnames=files
|
|
||||||
)
|
|
||||||
|
|
||||||
def mock_send(*args, **kwargs):
|
def mock_send(*args, **kwargs):
|
||||||
coder.partial_response_content = "ok"
|
coder.partial_response_content = "ok"
|
||||||
|
@ -320,7 +312,6 @@ class TestCoder(unittest.TestCase):
|
||||||
models.GPT4,
|
models.GPT4,
|
||||||
None,
|
None,
|
||||||
io=InputOutput(encoding=encoding),
|
io=InputOutput(encoding=encoding),
|
||||||
openai_api_key="fake_key",
|
|
||||||
fnames=files,
|
fnames=files,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -349,7 +340,7 @@ class TestCoder(unittest.TestCase):
|
||||||
mock_io = MagicMock()
|
mock_io = MagicMock()
|
||||||
|
|
||||||
# Initialize the Coder object with the mocked IO and mocked repo
|
# Initialize the Coder object with the mocked IO and mocked repo
|
||||||
coder = Coder.create(models.GPT4, None, mock_io, openai_api_key="fake_key")
|
coder = Coder.create(models.GPT4, None, mock_io)
|
||||||
|
|
||||||
# Set up the mock to raise InvalidRequestError
|
# Set up the mock to raise InvalidRequestError
|
||||||
mock_chat_completion_create.side_effect = openai.error.InvalidRequestError(
|
mock_chat_completion_create.side_effect = openai.error.InvalidRequestError(
|
||||||
|
@ -393,7 +384,6 @@ class TestCoder(unittest.TestCase):
|
||||||
models.GPT4,
|
models.GPT4,
|
||||||
None,
|
None,
|
||||||
io=InputOutput(),
|
io=InputOutput(),
|
||||||
openai_api_key="fake_key",
|
|
||||||
fnames=[str(tempdir / filenames[0])],
|
fnames=[str(tempdir / filenames[0])],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue