From 2f4e20658dc19553523b14846294600c708e8c11 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 11 Jul 2023 08:14:01 -0700 Subject: [PATCH] fix the test to mock git.execute not git.ls_files --- tests/test_coder.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_coder.py b/tests/test_coder.py index c4f95e06f..a7fc0fc92 100644 --- a/tests/test_coder.py +++ b/tests/test_coder.py @@ -30,7 +30,7 @@ class TestCoder(unittest.TestCase): # Mock the git repo mock_repo = MagicMock() - mock_repo.git.ls_files.return_value = "file1.txt\nfile2.py" + mock_repo.git.execute.return_value = "file1.txt\nfile2.py" coder.repo = mock_repo # Call the check_for_file_mentions method @@ -77,7 +77,7 @@ class TestCoder(unittest.TestCase): # Mock the git repo mock_repo = MagicMock() - mock_repo.git.ls_files.return_value = "file1.txt\nfile2.py" + mock_repo.git.execute.return_value = "file1.txt\nfile2.py" coder.repo = mock_repo # Call the check_for_file_mentions method @@ -104,7 +104,7 @@ class TestCoder(unittest.TestCase): # Mock the git repo mock_repo = MagicMock() - mock_repo.git.ls_files.return_value = "file1.txt\nother/file1.txt" + mock_repo.git.execute.return_value = "file1.txt\nother/file1.txt" coder.repo = mock_repo # Call the check_for_file_mentions method @@ -352,7 +352,9 @@ class TestCoder(unittest.TestCase): coder = Coder.create(models.GPT4, None, mock_io, openai_api_key="fake_key") # Set up the mock to raise InvalidRequestError - mock_chat_completion_create.side_effect = openai.error.InvalidRequestError("Invalid request", "param") + mock_chat_completion_create.side_effect = openai.error.InvalidRequestError( + "Invalid request", "param" + ) # Call the run method and assert that InvalidRequestError is raised with self.assertRaises(openai.error.InvalidRequestError):