Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
john-dupuy authored and gadomski committed Oct 13, 2022
1 parent f230eb6 commit d3d40b9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/test_stac_io.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import unittest
import tempfile
Expand Down Expand Up @@ -103,14 +104,13 @@ class ReportingStacIO(DefaultStacIO, DuplicateKeyReportingMixin):
def test_headers_stac_io(self, urlopen_mock: unittest.mock.MagicMock) -> None:
stac_io = DefaultStacIO(headers={"Authorization": "api-key fake-api-key-value"})

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

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

0 comments on commit d3d40b9

Please sign in to comment.