From c8cf78b5cf9be36731748b9b7eafd39f6cb505c2 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 27 May 2023 08:30:17 -0700 Subject: [PATCH] Added a new test to check for filename mentions of longer paths. --- tests/test_coder.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_coder.py b/tests/test_coder.py index 0995b0fda..0ea1bed54 100644 --- a/tests/test_coder.py +++ b/tests/test_coder.py @@ -26,6 +26,27 @@ class TestCoder(unittest.TestCase): expected_files = {os.path.abspath("file1.txt"), os.path.abspath("file2.py")} self.assertEqual(coder.abs_fnames, expected_files) + def test_check_for_filename_mentions_of_longer_paths(self): + # Mock the IO object + mock_io = MagicMock() + mock_io.get_input.return_value = "Please check file1.txt and file2.py" + mock_io.confirm_ask.return_value = True + + # Initialize the Coder object with the mocked IO and mocked repo + coder = Coder(io=mock_io, openai_api_key="fake_key") + + # Mock the git repo + mock_repo = MagicMock() + mock_repo.git.ls_files.return_value = "path/to/file1.txt\npath/to/file2.py" + coder.repo = mock_repo + + # Call the check_for_file_mentions method + coder.check_for_file_mentions("Please check file1.txt and file2.py") + + # Check if coder.abs_fnames contains both files + expected_files = {os.path.abspath("file1.txt"), os.path.abspath("file2.py")} + self.assertEqual(coder.abs_fnames, expected_files) + if __name__ == "__main__": unittest.main()