From 45442b99e16f4eb7e80be8931ca62c175368d8c7 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 24 May 2023 19:02:37 -0700 Subject: [PATCH] aider: Added test to check if `get_tags_map` function returns the expected tags map containing the file when `ctags=False`. # Context: USER: add another like that, but with ctags=False. just make sure the file is in the result. ASSISTANT: I will add a new test to the `tests/test_repomap.py` file that checks if the file is in the result when `ctags=False`. ```python tests/test_repomap.py <<<<<<< ORIGINAL self.assertIn("my_function", result) if __name__ == "__main__": unittest.main() ======= self.assertIn("my_function", result) def test_get_tags_map_without_ctags(self): # Create a temporary directory with a sample Python file containing identifiers test_file = "test_file_without_ctags.py" file_content = """\ class MyClass: def my_method(self, arg1, arg2): return arg1 + arg2 def my_function(arg1, arg2): return arg1 * arg2 """ with tempfile.TemporaryDirectory() as temp_dir: with open(os.path.join(temp_dir, test_file), "w") as f: f.write(file_content) repo_map = RepoMap(use_ctags=False, root=temp_dir) other_files = [os.path.join(temp_dir, test_file)] result = repo_map.get_tags_map(other_files) # Check if the result contains the expected tags map without ctags self.assertIn("test_file_without_ctags.py:", result) if __name__ == "__main__": unittest.main() >>>>>>> UPDATED ``` This new test creates a temporary directory with a sample Python file containing a class, a method, and a function. It then checks if the `get_tags_map` function returns the expected tags map containing the file when `ctags=False`. --- tests/test_repomap.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_repomap.py b/tests/test_repomap.py index 2d4d00ce9..fd67615ee 100644 --- a/tests/test_repomap.py +++ b/tests/test_repomap.py @@ -54,5 +54,28 @@ def my_function(arg1, arg2): self.assertIn("my_method", result) self.assertIn("my_function", result) + def test_get_tags_map_without_ctags(self): + # Create a temporary directory with a sample Python file containing identifiers + test_file = "test_file_without_ctags.py" + file_content = """\ +class MyClass: + def my_method(self, arg1, arg2): + return arg1 + arg2 + +def my_function(arg1, arg2): + return arg1 * arg2 +""" + + with tempfile.TemporaryDirectory() as temp_dir: + with open(os.path.join(temp_dir, test_file), "w") as f: + f.write(file_content) + + repo_map = RepoMap(use_ctags=False, root=temp_dir) + other_files = [os.path.join(temp_dir, test_file)] + result = repo_map.get_tags_map(other_files) + + # Check if the result contains the expected tags map without ctags + self.assertIn("test_file_without_ctags.py:", result) + if __name__ == "__main__": unittest.main()