File: test_simple.py

package info (click to toggle)
python-globus-sdk 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,172 kB
  • sloc: python: 35,227; sh: 44; makefile: 35
file content (41 lines) | stat: -rw-r--r-- 1,253 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
import json
import uuid

import pytest

from globus_sdk.testing import get_last_request, load_response


def test_get_endpoint(client):
    """
    Gets endpoint on fixture, validate results
    """
    meta = load_response(client.get_endpoint).metadata
    epid = meta["endpoint_id"]

    # load the endpoint document
    ep_doc = client.get_endpoint(epid)

    # check that the contents are basically OK
    assert ep_doc["DATA_TYPE"] == "endpoint"
    assert ep_doc["id"] == epid
    assert "display_name" in ep_doc


@pytest.mark.parametrize("epid_type", [uuid.UUID, str])
def test_update_endpoint(epid_type, client):
    meta = load_response(client.update_endpoint).metadata
    epid = meta["endpoint_id"]

    # NOTE: pass epid as UUID or str
    # requires that TransferClient correctly translates UUID
    update_data = {"display_name": "Updated Name", "description": "Updated description"}
    update_doc = client.update_endpoint(epid_type(epid), update_data)

    # make sure response is a successful update
    assert update_doc["DATA_TYPE"] == "result"
    assert update_doc["code"] == "Updated"
    assert update_doc["message"] == "Endpoint updated successfully"

    req = get_last_request()
    assert json.loads(req.body) == update_data