| 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_mkdir(client, local_user): |
| 14 |
meta = load_response(client.operation_mkdir).metadata |
| 15 |
endpoint_id = meta["endpoint_id"] |
| 16 |
|
| 17 |
if local_user is not _OMIT: |
| 18 |
res = client.operation_mkdir( |
| 19 |
endpoint_id=endpoint_id, |
| 20 |
path="~/dir/", |
| 21 |
local_user=local_user, |
| 22 |
query_params={"foo": "bar"}, |
| 23 |
) |
| 24 |
else: |
| 25 |
res = client.operation_mkdir( |
| 26 |
endpoint_id=endpoint_id, |
| 27 |
path="~/dir/", |
| 28 |
query_params={"foo": "bar"}, |
| 29 |
) |
| 30 |
assert res["DATA_TYPE"] == "mkdir_result" |
| 31 |
assert res["code"] == "DirectoryCreated" |
| 32 |
|
| 33 |
req = get_last_request() |
| 34 |
body = json.loads(req.body) |
| 35 |
assert body["path"] == "~/dir/" |
| 36 |
if local_user not in (_OMIT, MISSING): |
| 37 |
assert body["local_user"] == local_user |
| 38 |
else: |
| 39 |
assert "local_user" not in body |
| 40 |
query_params = urllib.parse.parse_qs(urllib.parse.urlparse(req.url).query) |
| 41 |
assert query_params["foo"] == ["bar"] |