| 1 |
from globus_sdk import __version__ |
| 2 |
from globus_sdk.testing import RegisteredResponse, get_last_request |
| 3 |
|
| 4 |
|
| 5 |
def test_clientinfo_header_default(client): |
| 6 |
RegisteredResponse( |
| 7 |
path="https://foo.api.globus.org/bar", |
| 8 |
json={"foo": "bar"}, |
| 9 |
).add() |
| 10 |
res = client.request("GET", "/bar") |
| 11 |
assert res.http_status == 200 |
| 12 |
|
| 13 |
req = get_last_request() |
| 14 |
assert "X-Globus-Client-Info" in req.headers |
| 15 |
assert ( |
| 16 |
req.headers["X-Globus-Client-Info"] |
| 17 |
== f"product=python-sdk,version={__version__}" |
| 18 |
) |
| 19 |
|
| 20 |
|
| 21 |
def test_clientinfo_header_can_be_supressed(client): |
| 22 |
RegisteredResponse( |
| 23 |
path="https://foo.api.globus.org/bar", |
| 24 |
json={"foo": "bar"}, |
| 25 |
).add() |
| 26 |
|
| 27 |
# clear the X-Globus-Client-Info header |
| 28 |
client.transport.globus_client_info.clear() |
| 29 |
|
| 30 |
res = client.request("GET", "/bar") |
| 31 |
assert res.http_status == 200 |
| 32 |
|
| 33 |
req = get_last_request() |
| 34 |
assert "X-Globus-Client-Info" not in req.headers |