mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-02-05 14:24:27 +01:00
rename search_files to list_files (#3595)
This commit is contained in:
@@ -200,9 +200,9 @@ def delete_file(filename: str) -> str:
|
||||
return f"Error: {str(e)}"
|
||||
|
||||
|
||||
@command("search_files", "Search Files", '"directory": "<directory>"')
|
||||
def search_files(directory: str) -> list[str]:
|
||||
"""Search for files in a directory
|
||||
@command("list_files", "List Files in Directory", '"directory": "<directory>"')
|
||||
def list_files(directory: str) -> list[str]:
|
||||
"""lists files in a directory recursively
|
||||
|
||||
Args:
|
||||
directory (str): The directory to search in
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user