Skip to content

Commit

Permalink
rename search_files to list_files (Significant-Gravitas#3595)
Browse files Browse the repository at this point in the history
  • Loading branch information
richbeales authored Apr 30, 2023
1 parent abd6115 commit c1329c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit c1329c9

Please sign in to comment.