File: test_operation_rename.py

package info (click to toggle)
python-globus-sdk 4.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,144 kB
  • sloc: python: 35,242; sh: 37; makefile: 35
file content (44 lines) | stat: -rw-r--r-- 1,334 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import json
import urllib.parse

import pytest

from globus_sdk import MISSING
from globus_sdk.testing import get_last_request, load_response

_OMIT = object()


@pytest.mark.parametrize("local_user", ("my-user", MISSING, _OMIT))
def test_operation_rename(client, local_user):
    meta = load_response(client.operation_rename).metadata
    endpoint_id = meta["endpoint_id"]

    if local_user is not _OMIT:
        res = client.operation_rename(
            endpoint_id=endpoint_id,
            oldpath="~/old-name",
            newpath="~/new-name",
            local_user=local_user,
            query_params={"foo": "bar"},
        )
    else:
        res = client.operation_rename(
            endpoint_id=endpoint_id,
            oldpath="~/old-name",
            newpath="~/new-name",
            query_params={"foo": "bar"},
        )
    assert res["DATA_TYPE"] == "result"
    assert res["code"] == "FileRenamed"

    req = get_last_request()
    body = json.loads(req.body)
    assert body["old_path"] == "~/old-name"
    assert body["new_path"] == "~/new-name"
    if local_user not in (_OMIT, MISSING):
        assert body["local_user"] == local_user
    else:
        assert "local_user" not in body
    query_params = urllib.parse.parse_qs(urllib.parse.urlparse(req.url).query)
    assert query_params["foo"] == ["bar"]