Skip to content

Commit

Permalink
Add responses for ls
Browse files Browse the repository at this point in the history
  • Loading branch information
ekouts committed Oct 23, 2024
1 parent 3778343 commit 5f16101
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
26 changes: 10 additions & 16 deletions firecrest/v2/AsyncClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,24 +288,17 @@ async def list_files(
:param follow_links: Follow symbolik links
:calls: GET `/filesystem/{system_name}/ops/ls`
"""
params: dict[str, Any] = {"path": f"{path}"}
if show_hidden is True:
params["showHidden"] = show_hidden

if recursive is True:
params["recursive"] = recursive

if numeric_uid is True:
params["numericUid"] = numeric_uid

if follow_links is True:
params["followLinks"] = follow_links

resp = await self._get_request(
endpoint=f"/filesystem/{system_name}/ops/ls",
params=params
params={
"path": path,
"showHidden": show_hidden,
"recursive": recursive,
"numericUid": numeric_uid,
"followLinks": follow_links
}
)
return self._json_response(resp, 200)
return self._json_response(resp, 200)["output"]

async def head(
self,
Expand Down Expand Up @@ -623,7 +616,8 @@ async def cp(
target_path: str
) -> List[dict]:
"""Copies file from `source_path` to `target_path`.
When successful, the method returns a string with the path of the newly created file.
When successful, the method returns a string with the path of the
newly created file.
:param system_name: the system name where the filesystem belongs to
:param source_path: the absolute source path
Expand Down
17 changes: 17 additions & 0 deletions tests/v2/responses/ls_home.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"status_code": 200,
"response": {
"output": [
{
"name": "bin",
"type": "d",
"linkTarget": null,
"user": "test1",
"group": "users",
"permissions": "rwxr-xr-x",
"lastModified": "2022-03-15T11:33:15",
"size": "4096"
}
]
}
}
10 changes: 10 additions & 0 deletions tests/v2/responses/ls_invalid_path.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"status_code": 404,
"response": {
"errorType": "error",
"message": "ls: cannot access '/home/test23': No such file or directory",
"data": null,
"user": "test1",
"authHeader": "Bearer token"
}
}

0 comments on commit 5f16101

Please sign in to comment.