| 1 |
import json |
| 2 |
import urllib.parse |
| 3 |
|
| 4 |
import pytest |
| 5 |
|
| 6 |
from globus_sdk import MISSING |
| 7 |
from globus_sdk.testing import get_last_request, load_response |
| 8 |
|
| 9 |
_OMIT = object() |
| 10 |
|
| 11 |
|
| 12 |
@pytest.mark.parametrize("local_user", ("my-user", MISSING, _OMIT)) |
| 13 |
def test_operation_rename(client, local_user): |
| 14 |
meta = load_response(client.operation_rename).metadata |
| 15 |
endpoint_id = meta["endpoint_id"] |
| 16 |
|
| 17 |
if local_user is not _OMIT: |
| 18 |
res = client.operation_rename( |
| 19 |
endpoint_id=endpoint_id, |
| 20 |
oldpath="~/old-name", |
| 21 |
newpath="~/new-name", |
| 22 |
local_user=local_user, |
| 23 |
query_params={"foo": "bar"}, |
| 24 |
) |
| 25 |
else: |
| 26 |
res = client.operation_rename( |
| 27 |
endpoint_id=endpoint_id, |
| 28 |
oldpath="~/old-name", |
| 29 |
newpath="~/new-name", |
| 30 |
query_params={"foo": "bar"}, |
| 31 |
) |
| 32 |
assert res["DATA_TYPE"] == "result" |
| 33 |
assert res["code"] == "FileRenamed" |
| 34 |
|
| 35 |
req = get_last_request() |
| 36 |
body = json.loads(req.body) |
| 37 |
assert body["old_path"] == "~/old-name" |
| 38 |
assert body["new_path"] == "~/new-name" |
| 39 |
if local_user not in (_OMIT, MISSING): |
| 40 |
assert body["local_user"] == local_user |
| 41 |
else: |
| 42 |
assert "local_user" not in body |
| 43 |
query_params = urllib.parse.parse_qs(urllib.parse.urlparse(req.url).query) |
| 44 |
assert query_params["foo"] == ["bar"] |