| 1 |
import json |
| 2 |
import uuid |
| 3 |
|
| 4 |
import pytest |
| 5 |
|
| 6 |
from globus_sdk.testing import get_last_request, load_response |
| 7 |
|
| 8 |
|
| 9 |
def test_get_endpoint(client): |
| 10 |
""" |
| 11 |
Gets endpoint on fixture, validate results |
| 12 |
""" |
| 13 |
meta = load_response(client.get_endpoint).metadata |
| 14 |
epid = meta["endpoint_id"] |
| 15 |
|
| 16 |
# load the endpoint document |
| 17 |
ep_doc = client.get_endpoint(epid) |
| 18 |
|
| 19 |
# check that the contents are basically OK |
| 20 |
assert ep_doc["DATA_TYPE"] == "endpoint" |
| 21 |
assert ep_doc["id"] == epid |
| 22 |
assert "display_name" in ep_doc |
| 23 |
|
| 24 |
|
| 25 |
@pytest.mark.parametrize("epid_type", [uuid.UUID, str]) |
| 26 |
def test_update_endpoint(epid_type, client): |
| 27 |
meta = load_response(client.update_endpoint).metadata |
| 28 |
epid = meta["endpoint_id"] |
| 29 |
|
| 30 |
# NOTE: pass epid as UUID or str |
| 31 |
# requires that TransferClient correctly translates UUID |
| 32 |
update_data = {"display_name": "Updated Name", "description": "Updated description"} |
| 33 |
update_doc = client.update_endpoint(epid_type(epid), update_data) |
| 34 |
|
| 35 |
# make sure response is a successful update |
| 36 |
assert update_doc["DATA_TYPE"] == "result" |
| 37 |
assert update_doc["code"] == "Updated" |
| 38 |
assert update_doc["message"] == "Endpoint updated successfully" |
| 39 |
|
| 40 |
req = get_last_request() |
| 41 |
assert json.loads(req.body) == update_data |