File: test_default_headers.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 (34 lines) | stat: -rw-r--r-- 950 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
from globus_sdk import __version__
from globus_sdk.testing import RegisteredResponse, get_last_request


def test_clientinfo_header_default(client):
    RegisteredResponse(
        path="https://foo.api.globus.org/bar",
        json={"foo": "bar"},
    ).add()
    res = client.request("GET", "/bar")
    assert res.http_status == 200

    req = get_last_request()
    assert "X-Globus-Client-Info" in req.headers
    assert (
        req.headers["X-Globus-Client-Info"]
        == f"product=python-sdk,version={__version__}"
    )


def test_clientinfo_header_can_be_supressed(client):
    RegisteredResponse(
        path="https://foo.api.globus.org/bar",
        json={"foo": "bar"},
    ).add()

    # clear the X-Globus-Client-Info header
    client.transport.globus_client_info.clear()

    res = client.request("GET", "/bar")
    assert res.http_status == 200

    req = get_last_request()
    assert "X-Globus-Client-Info" not in req.headers