| 1 |
""" |
| 2 |
Tests for IterableTransferResponse responses from TransferClient |
| 3 |
""" |
| 4 |
|
| 5 |
import globus_sdk |
| 6 |
from tests.common import register_api_route |
| 7 |
|
| 8 |
SERVER_LIST_TEXT = """{ |
| 9 |
"DATA": [ |
| 10 |
{ |
| 11 |
"DATA_TYPE": "server", |
| 12 |
"hostname": "ep1.transfer.globus.org", |
| 13 |
"id": 207976, |
| 14 |
"incoming_data_port_end": null, |
| 15 |
"incoming_data_port_start": null, |
| 16 |
"is_connected": true, |
| 17 |
"is_paused": false, |
| 18 |
"outgoing_data_port_end": null, |
| 19 |
"outgoing_data_port_start": null, |
| 20 |
"port": 2811, |
| 21 |
"scheme": "gsiftp", |
| 22 |
"subject": null, |
| 23 |
"uri": "gsiftp://ep1.transfer.globus.org:2811" |
| 24 |
} |
| 25 |
], |
| 26 |
"DATA_TYPE": "endpoint_server_list", |
| 27 |
"endpoint": "go#ep1" |
| 28 |
}""" |
| 29 |
|
| 30 |
|
| 31 |
def test_server_list(client): |
| 32 |
epid = "epid" |
| 33 |
register_api_route( |
| 34 |
"transfer", f"/endpoint/{epid}/server_list", body=SERVER_LIST_TEXT |
| 35 |
) |
| 36 |
|
| 37 |
res = client.endpoint_server_list(epid) |
| 38 |
# it should still be a subclass of GlobusHTTPResponse |
| 39 |
assert isinstance(res, globus_sdk.GlobusHTTPResponse) |
| 40 |
|
| 41 |
# fetch top-level attrs |
| 42 |
assert res["DATA_TYPE"] == "endpoint_server_list" |
| 43 |
assert res["endpoint"] == "go#ep1" |
| 44 |
|
| 45 |
# intentionally access twice -- unlike PaginatedResource, this is allowed |
| 46 |
# and works |
| 47 |
assert len(list(res)) == 1 |
| 48 |
assert len(list(res)) == 1 |
| 49 |
|
| 50 |
assert list(res)[0]["DATA_TYPE"] == "server" |