| 1 |
import pytest |
| 2 |
|
| 3 |
import globus_sdk |
| 4 |
from globus_sdk.testing import load_response |
| 5 |
|
| 6 |
|
| 7 |
def test_set_subscription_id(client): |
| 8 |
meta = load_response(client.set_subscription_id).metadata |
| 9 |
epid = meta["endpoint_id"] |
| 10 |
|
| 11 |
res = client.set_subscription_id(epid, "DEFAULT") |
| 12 |
assert res["code"] == "Updated" |
| 13 |
assert res["message"] == "Endpoint updated successfully" |
| 14 |
|
| 15 |
|
| 16 |
def test_set_subscription_id_fails_notfound(client): |
| 17 |
meta = load_response(client.set_subscription_id, case="not_found").metadata |
| 18 |
epid = meta["endpoint_id"] |
| 19 |
|
| 20 |
with pytest.raises(globus_sdk.TransferAPIError) as excinfo: |
| 21 |
client.set_subscription_id(epid, "DEFAULT") |
| 22 |
|
| 23 |
assert excinfo.value.code == "EndpointNotFound" |
| 24 |
assert excinfo.value.messages == [f"No such endpoint '{epid}'"] |
| 25 |
|
| 26 |
|
| 27 |
def test_set_subscription_id_fails_multi(client): |
| 28 |
meta = load_response( |
| 29 |
client.set_subscription_id, case="multi_subscriber_cannot_use_default" |
| 30 |
).metadata |
| 31 |
epid = meta["endpoint_id"] |
| 32 |
|
| 33 |
with pytest.raises(globus_sdk.TransferAPIError) as excinfo: |
| 34 |
client.set_subscription_id(epid, "DEFAULT") |
| 35 |
|
| 36 |
assert excinfo.value.code == "BadRequest" |
| 37 |
assert len(excinfo.value.messages) == 1 |
| 38 |
message = excinfo.value.messages[0] |
| 39 |
assert message.startswith("Please specify the subscription ID to use.") |