Skip to content

Commit d3d40b9

Browse files
john-dupuygadomski
authored andcommitted
Address review comments
1 parent f230eb6 commit d3d40b9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/test_stac_io.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23
import unittest
34
import tempfile
@@ -103,14 +104,13 @@ class ReportingStacIO(DefaultStacIO, DuplicateKeyReportingMixin):
103104
def test_headers_stac_io(self, urlopen_mock: unittest.mock.MagicMock) -> None:
104105
stac_io = DefaultStacIO(headers={"Authorization": "api-key fake-api-key-value"})
105106

106-
try:
107-
# note we don't care if this raises an exception, we just want to make
108-
# sure urlopen was called with the appropriate headers
109-
pystac.Catalog.from_file(
110-
"https://example.com/catalog.json", stac_io=stac_io
111-
)
112-
except Exception:
113-
pass
107+
catalog = pystac.Catalog("an-id", "a description").to_dict()
108+
# required until https://github.com/stac-utils/pystac/pull/896 is merged
109+
catalog["links"] = []
110+
urlopen_mock.return_value.__enter__.return_value.read.return_value = json.dumps(
111+
catalog
112+
).encode("utf-8")
113+
pystac.Catalog.from_file("https://example.com/catalog.json", stac_io=stac_io)
114114

115115
request_obj = urlopen_mock.call_args[0][0]
116116
self.assertEqual(request_obj.headers, stac_io.headers)

0 commit comments

Comments
 (0)