Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename search_files to list_files #3595

Merged
merged 3 commits into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions autogpt/commands/file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
check_duplicate_operation,
delete_file,
download_file,
list_files,
log_operation,
read_file,
search_files,
split_file,
write_to_file,
)
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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


Expand Down