File tree 1 file changed +8
-8
lines changed
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change
1
+ import json
1
2
import os
2
3
import unittest
3
4
import tempfile
@@ -103,14 +104,13 @@ class ReportingStacIO(DefaultStacIO, DuplicateKeyReportingMixin):
103
104
def test_headers_stac_io (self , urlopen_mock : unittest .mock .MagicMock ) -> None :
104
105
stac_io = DefaultStacIO (headers = {"Authorization" : "api-key fake-api-key-value" })
105
106
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 )
114
114
115
115
request_obj = urlopen_mock .call_args [0 ][0 ]
116
116
self .assertEqual (request_obj .headers , stac_io .headers )
You can’t perform that action at this time.
0 commit comments