-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #868 from sirosen/add-ls-params
Add support for limit and offset to ls
- Loading branch information
Showing
5 changed files
with
122 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Added | ||
~~~~~ | ||
|
||
- ``TransferClient.operation_ls`` now supports the ``limit`` and ``offset`` | ||
parameters (:pr:`NUMBER`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 0 additions & 79 deletions
79
tests/functional/services/transfer/fixture_data/operation_ls_goep1.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import urllib.parse | ||
|
||
import pytest | ||
|
||
from globus_sdk._testing import RegisteredResponse, get_last_request, load_response | ||
from tests.common import GO_EP1_ID | ||
|
||
|
||
def _mk_item(*, name, typ, size=0): | ||
return { | ||
"DATA_TYPE": "file", | ||
"group": "tutorial", | ||
"last_modified": "2018-04-04 18:30:26+00:00", | ||
"link_group": None, | ||
"link_last_modified": None, | ||
"link_size": None, | ||
"link_target": None, | ||
"link_user": None, | ||
"name": name, | ||
"permissions": "0755" if typ == "dir" else "0644", | ||
"size": 4096 if typ == "dir" else size, | ||
"type": typ, | ||
"user": "snork", | ||
} | ||
|
||
|
||
def _mk_ls_data(): | ||
return { | ||
"DATA": [ | ||
_mk_item(name="foo", typ="dir"), | ||
_mk_item(name="tempdir1", typ="dir"), | ||
_mk_item(name=".bashrc", typ="file", size=3771), | ||
_mk_item(name=".profile", typ="file", size=807), | ||
] | ||
} | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def _setup_ls_response(): | ||
load_response( | ||
RegisteredResponse( | ||
service="transfer", | ||
path=f"/operation/endpoint/{GO_EP1_ID}/ls", | ||
json=_mk_ls_data(), | ||
), | ||
) | ||
|
||
|
||
def test_operation_ls(client): | ||
ls_path = f"https://transfer.api.globus.org/v0.10/operation/endpoint/{GO_EP1_ID}/ls" | ||
|
||
# load the tutorial endpoint ls doc | ||
ls_doc = client.operation_ls(GO_EP1_ID) | ||
|
||
# check that the result is an iterable of file and dir dict objects | ||
for x in ls_doc: | ||
assert "DATA_TYPE" in x | ||
assert x["DATA_TYPE"] in ("file", "dir") | ||
|
||
req = get_last_request() | ||
assert req.url == ls_path | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"kwargs, expected_qs", | ||
[ | ||
# orderby with a single str | ||
({"orderby": "name"}, {"orderby": ["name"]}), | ||
# orderby with a multiple strs | ||
( | ||
{"orderby": ["size DESC", "name", "type"]}, | ||
{"orderby": ["size DESC,name,type"]}, | ||
), | ||
# orderby + filter | ||
( | ||
{"orderby": "name", "filter": "name:~*.png"}, | ||
{"orderby": ["name"], "filter": ["name:~*.png"]}, | ||
), | ||
# local_user | ||
( | ||
{"local_user": "my-user"}, | ||
{"local_user": ["my-user"]}, | ||
), | ||
# limit+offset | ||
( | ||
{"limit": 10, "offset": 5}, | ||
{"limit": ["10"], "offset": ["5"]}, | ||
), | ||
], | ||
) | ||
def test_operation_ls_params(client, kwargs, expected_qs): | ||
client.operation_ls(GO_EP1_ID, **kwargs) | ||
req = get_last_request() | ||
parsed_qs = urllib.parse.parse_qs(urllib.parse.urlparse(req.url).query) | ||
assert parsed_qs == expected_qs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters