From c1329c92fde62bd09084f00dead1cf07845eea1e Mon Sep 17 00:00:00 2001 From: Richard Beales Date: Sun, 30 Apr 2023 22:14:53 +0100 Subject: [PATCH] rename search_files to list_files (#3595) --- autogpt/commands/file_operations.py | 6 +++--- tests/unit/test_file_operations.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/autogpt/commands/file_operations.py b/autogpt/commands/file_operations.py index e9afdaea..c54fb054 100644 --- a/autogpt/commands/file_operations.py +++ b/autogpt/commands/file_operations.py @@ -200,9 +200,9 @@ def delete_file(filename: str) -> str: return f"Error: {str(e)}" -@command("search_files", "Search Files", '"directory": ""') -def search_files(directory: str) -> list[str]: - """Search for files in a directory +@command("list_files", "List Files in Directory", '"directory": ""') +def list_files(directory: str) -> list[str]: + """lists files in a directory recursively Args: directory (str): The directory to search in diff --git a/tests/unit/test_file_operations.py b/tests/unit/test_file_operations.py index f324193a..e7ba2f71 100644 --- a/tests/unit/test_file_operations.py +++ b/tests/unit/test_file_operations.py @@ -13,9 +13,9 @@ from autogpt.commands.file_operations import ( check_duplicate_operation, delete_file, download_file, + list_files, log_operation, read_file, - search_files, split_file, write_to_file, ) @@ -113,7 +113,7 @@ def test_delete_missing_file(test_file): assert True, "Failed to test delete_file" -def test_search_files(config, workspace, test_directory): +def test_list_files(config, workspace, test_directory): # Case 1: Create files A and B, search for A, and ensure we don't return A and B file_a = workspace.get_path("file_a.txt") file_b = workspace.get_path("file_b.txt") @@ -131,7 +131,7 @@ def test_search_files(config, workspace, test_directory): with open(os.path.join(test_directory, file_a.name), "w") as f: f.write("This is file A in the subdirectory.") - files = search_files(str(workspace.root)) + files = list_files(str(workspace.root)) assert file_a.name in files assert file_b.name in files assert os.path.join(Path(test_directory).name, file_a.name) in files @@ -144,7 +144,7 @@ def test_search_files(config, workspace, test_directory): # Case 2: Search for a file that does not exist and make sure we don't throw non_existent_file = "non_existent_file.txt" - files = search_files("") + files = list_files("") assert non_existent_file not in files