Skip to content

Commit 30d793a

Browse files
committed
Add test for custom headers in StacApiIO
1 parent 17d3909 commit 30d793a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_stac_api_io.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,19 @@ def test_conforms_to(self):
5959

6060
# Check that this does not raise an exception
6161
assert conformant_io.conforms_to(ConformanceClasses.CORE)
62+
63+
def test_custom_headers(self, requests_mock):
64+
"""Checks that headers passed to the init method are added to requests."""
65+
header_name = "x-my-header"
66+
header_value = "Some Value"
67+
url = "https://some-url.com/some-file.json"
68+
stac_api_io = StacApiIO(headers={header_name: header_value})
69+
70+
requests_mock.get(url, status_code=200, json={})
71+
72+
stac_api_io.read_json(url)
73+
74+
history = requests_mock.request_history
75+
assert len(history) == 1
76+
assert header_name in history[0].headers
77+
assert history[0].headers[header_name] == header_value

0 commit comments

Comments
 (0)