Bug#1073441: pystac-client: FTBFS: dh_auto_test: error: pybuild --test --test-pytest -i python{version} -p "3.12 3.11" returned exit code 13
Lucas Nussbaum
lucas at debian.org
Sun Jun 16 14:23:09 BST 2024
Source: pystac-client
Version: 0.8.2-1
Severity: serious
Justification: FTBFS
Tags: trixie sid ftbfs
User: lucas at debian.org
Usertags: ftbfs-20240615 ftbfs-trixie
Hi,
During a rebuild of all packages in sid, your package failed to build
on amd64.
Relevant part (hopefully):
> make[1]: Entering directory '/<<PKGBUILDDIR>>'
> env https_proxy="" dh_auto_test
> I: pybuild base:311: cd /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build; python3.12 -m pytest -k "not test_localized_datetime_converted_to_utc" --block-network
> ============================= test session starts ==============================
> platform linux -- Python 3.12.4, pytest-8.2.2, pluggy-1.5.0
> benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
> rootdir: /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build
> configfile: pyproject.toml
> plugins: requests-mock-1.11.0, console-scripts-1.4.1, recording-0.13.1, benchmark-4.0.0
> collected 159 items / 1 deselected / 158 selected
>
> tests/test_cli.py F.FFF...............F.... [ 15%]
> tests/test_client.py FFF..................FFFFF........FFFF [ 39%]
> tests/test_collection_client.py FFFFFF [ 43%]
> tests/test_item_search.py sss........................................... [ 72%]
> ..FFFF.FFFFFFFFFFF...... [ 87%]
> tests/test_stac_api_io.py FF..............F.. [100%]
>
> =================================== FAILURES ===================================
> __________________ TestCLISearch.test_item_search[inprocess] ___________________
>
> self = <tests.test_cli.TestCLISearch object at 0x7fb9e5793140>
> script_runner = <ScriptRunner inprocess>
>
> @pytest.mark.vcr
> def test_item_search(self, script_runner: ScriptRunner) -> None:
> args = [
> "stac-client",
> "search",
> STAC_URLS["PLANETARY-COMPUTER"],
> "-c",
> "naip",
> "--max-items",
> "20",
> ]
> result = script_runner.run(args, print_result=False)
> > assert result.success
> E assert False
> E + where False = <pytest_console_scripts.RunResult object at 0x7fb9e54ee2a0>.success
>
> tests/test_cli.py:29: AssertionError
> ________ TestCLISearch.test_intersects[inprocess-netherlands_aoi.json] _________
>
> self = <tests.test_cli.TestCLISearch object at 0x7fb9e5237140>
> script_runner = <ScriptRunner inprocess>, filename = 'netherlands_aoi.json'
>
> @pytest.mark.vcr
> @pytest.mark.parametrize("filename", ["netherlands_aoi.json", "sample-item.json"])
> def test_intersects(self, script_runner: ScriptRunner, filename: str) -> None:
> args = [
> "stac-client",
> "search",
> STAC_URLS["PLANETARY-COMPUTER"],
> "--collections",
> "landsat-8-c2-l2",
> "--intersects",
> str(TEST_DATA / filename),
> "--max-items",
> "10",
> ]
> result = script_runner.run(args, print_result=False)
> > assert result.success, result.stderr
> E AssertionError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E Traceback (most recent call last):
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/stac_api_io.py", line 222, in request
> E return resp.content.decode("utf-8")
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E
> E During handling of the above exception, another exception occurred:
> E
> E Traceback (most recent call last):
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/cli.py", line 349, in cli
> E client = Client.open(url, headers=headers)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/client.py", line 169, in open
> E client: Client = cls.from_file(
> E ^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/client.py", line 225, in from_file
> E client: Client = super().from_file(href, stac_io)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/catalog.py", line 1273, in from_file
> E result = super().from_file(href, stac_io)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/stac_object.py", line 629, in from_file
> E d = stac_io.read_json(href)
> E ^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/stac_io.py", line 205, in read_json
> E txt = self.read_text(source, *args, **kwargs)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/stac_api_io.py", line 168, in read_text
> E return self.request(href, *args, **kwargs)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/stac_api_io.py", line 224, in request
> E raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E
> E assert False
> E + where False = <pytest_console_scripts.RunResult object at 0x7fb9e5792750>.success
>
> tests/test_cli.py:61: AssertionError
> __________ TestCLISearch.test_intersects[inprocess-sample-item.json] ___________
>
> self = <tests.test_cli.TestCLISearch object at 0x7fb9e5237170>
> script_runner = <ScriptRunner inprocess>, filename = 'sample-item.json'
>
> @pytest.mark.vcr
> @pytest.mark.parametrize("filename", ["netherlands_aoi.json", "sample-item.json"])
> def test_intersects(self, script_runner: ScriptRunner, filename: str) -> None:
> args = [
> "stac-client",
> "search",
> STAC_URLS["PLANETARY-COMPUTER"],
> "--collections",
> "landsat-8-c2-l2",
> "--intersects",
> str(TEST_DATA / filename),
> "--max-items",
> "10",
> ]
> result = script_runner.run(args, print_result=False)
> > assert result.success, result.stderr
> E AssertionError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E Traceback (most recent call last):
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/stac_api_io.py", line 222, in request
> E return resp.content.decode("utf-8")
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E
> E During handling of the above exception, another exception occurred:
> E
> E Traceback (most recent call last):
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/cli.py", line 349, in cli
> E client = Client.open(url, headers=headers)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/client.py", line 169, in open
> E client: Client = cls.from_file(
> E ^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/client.py", line 225, in from_file
> E client: Client = super().from_file(href, stac_io)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/catalog.py", line 1273, in from_file
> E result = super().from_file(href, stac_io)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/stac_object.py", line 629, in from_file
> E d = stac_io.read_json(href)
> E ^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/stac_io.py", line 205, in read_json
> E txt = self.read_text(source, *args, **kwargs)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/stac_api_io.py", line 168, in read_text
> E return self.request(href, *args, **kwargs)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pystac_client/stac_api_io.py", line 224, in request
> E raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E
> E assert False
> E + where False = <pytest_console_scripts.RunResult object at 0x7fb9e57d8500>.success
>
> tests/test_cli.py:61: AssertionError
> ___________ TestCLISearch.test_intersects_despite_warning[inprocess] ___________
>
> self = <tests.test_cli.TestCLISearch object at 0x7fb9e5237530>
> script_runner = <ScriptRunner inprocess>
>
> @pytest.mark.vcr
> def test_intersects_despite_warning(self, script_runner: ScriptRunner) -> None:
> args = [
> "stac-client",
> "search",
> STAC_URLS["PLANETARY-COMPUTER"],
> "--collections",
> "landsat-8-c2-l2",
> "--intersects",
> str(TEST_DATA / "sample-item-collection.json"),
> "--max-items",
> "10",
> ]
> result = script_runner.run(args, print_result=False)
> > assert result.success
> E assert False
> E + where False = <pytest_console_scripts.RunResult object at 0x7fb9e52c2db0>.success
>
> tests/test_cli.py:78: AssertionError
> _____________ TestCLISearch.test_matched_not_available[inprocess] ______________
>
> self = <tests.test_cli.TestCLISearch object at 0x7fb9e524d910>
> script_runner = <ScriptRunner inprocess>
>
> @pytest.mark.vcr
> @pytest.mark.filterwarnings("ignore::Warning")
> def test_matched_not_available(self, script_runner: ScriptRunner) -> None:
> args = [
> "stac-client",
> "search",
> STAC_URLS["PLANETARY-COMPUTER"],
> "-c",
> "naip",
> "--matched",
> ]
> result = script_runner.run(args, print_result=False)
> assert result.success is False
> > assert "'matched' is not supported for this catalog" in result.stderr
> E assert "'matched' is not supported for this catalog" in "INFO:vcr.stubs:Playing response for <Request (GET) https://planetarycomputer.microsoft.com/api/stac/v1> from cassette...str(err))\npystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte\n"
> E + where "INFO:vcr.stubs:Playing response for <Request (GET) https://planetarycomputer.microsoft.com/api/stac/v1> from cassette...str(err))\npystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte\n" = <pytest_console_scripts.RunResult object at 0x7fb9e4f01fa0>.stderr
>
> tests/test_cli.py:211: AssertionError
> ____________________________ TestAPI.test_instance _____________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4f83560>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestAPI object at 0x7fb9e5262720>
>
> @pytest.mark.vcr
> def test_instance(self) -> None:
> > api = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_client.py:35:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4f83560>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________________ TestAPI.test_links ______________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5279670>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestAPI object at 0x7fb9e5262450>
>
> @pytest.mark.vcr
> def test_links(self) -> None:
> > api = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_client.py:44:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5279670>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____________________________ TestAPI.test_from_file ____________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e52799d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestAPI object at 0x7fb9e5261e80>
>
> @pytest.mark.vcr
> def test_from_file(self) -> None:
> > api = Client.from_file(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_client.py:60:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e52799d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____________ TestAPISearch.test_search_max_items_unlimited_default _____________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4ed8740>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 45.05), 'collections': ('naip',), 'datetime': '2014-01-01T00:00:00Z/2020-12-31T23:59:59Z'}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestAPISearch object at 0x7fb9e524f290>
> api = <Client id=microsoft-pc>
>
> @pytest.mark.vcr
> def test_search_max_items_unlimited_default(self, api: Client) -> None:
> search = api.search(
> bbox=[-73.21, 43.99, -73.12, 45.05],
> collections="naip",
> datetime="2014-01-01/2020-12-31",
> )
> > items = list(search.items())
>
> tests/test_client.py:503:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4ed8740>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 45.05), 'collections': ('naip',), 'datetime': '2014-01-01T00:00:00Z/2020-12-31T23:59:59Z'}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ___________________________ TestSigning.test_signing ___________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4edbfe0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestSigning object at 0x7fb9e524dd00>
>
> @pytest.mark.vcr
> def test_signing(self) -> None:
> sign = MySign()
> # sign is callable, but mypy keeps trying to interpret it as a "MySign" object.
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"], modifier=sign)
>
> tests/test_client.py:520:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4edbfe0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ___________________ TestSigning.test_sign_with_return_warns ____________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4ed9b20>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestSigning object at 0x7fb9e5278aa0>
>
> @pytest.mark.vcr
> def test_sign_with_return_warns(self) -> None:
> def modifier_ok(x: Any) -> Any:
> return x
>
> def modifier_bad(x: Any) -> Any:
> return 0
>
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"], modifier=modifier_ok)
>
> tests/test_client.py:568:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4ed9b20>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestQueryables.test_get_queryables ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e52d08f0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestQueryables object at 0x7fb9e52793d0>
>
> @pytest.mark.vcr
> def test_get_queryables(self) -> None:
> > api = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_client.py:581:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e52d08f0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ________________ TestQueryables.test_get_queryables_collections ________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e510b950>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestQueryables object at 0x7fb9e50a5c40>
>
> @pytest.mark.vcr
> def test_get_queryables_collections(self) -> None:
> > api = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_client.py:589:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e510b950>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________________________ test_collections_are_clients _________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4eff6e0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> @pytest.mark.vcr
> def test_collections_are_clients() -> None:
> # https://github.com/stac-utils/pystac-client/issues/548
> > catalog = Client.open(
> "https://planetarycomputer.microsoft.com/api/stac/v1/",
> )
>
> tests/test_client.py:691:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4eff6e0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> __________________________ test_get_items_without_ids __________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5151e20>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> @pytest.mark.vcr
> def test_get_items_without_ids() -> None:
> > client = Client.open(
> "https://planetarycomputer.microsoft.com/api/stac/v1/",
> )
>
> tests/test_client.py:703:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5151e20>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ________________________ test_non_recursion_on_fallback ________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4f80c80>
> href = 'https://raw.githubusercontent.com/stac-utils/pystac/v1.9.0/docs/example-catalog/catalog.json'
> method = None, headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> @pytest.mark.vcr
> def test_non_recursion_on_fallback() -> None:
> path = "https://raw.githubusercontent.com/stac-utils/pystac/v1.9.0/docs/example-catalog/catalog.json"
> > catalog = Client.from_file(path)
>
> tests/test_client.py:712:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4f80c80>
> href = 'https://raw.githubusercontent.com/stac-utils/pystac/v1.9.0/docs/example-catalog/catalog.json'
> method = None, headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____________________________ test_fallback_strategy ____________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4f82300>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> @pytest.mark.vcr
> def test_fallback_strategy() -> None:
> """Make sure links get recreated correctly using APILayoutStrategy."""
>
> > client = Client.open(
> "https://planetarycomputer.microsoft.com/api/stac/v1/",
> )
>
> tests/test_client.py:721:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4f82300>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestCollectionClient.test_instance ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4eb99d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7fb9e50a5850>
>
> @pytest.mark.vcr
> def test_instance(self) -> None:
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:13:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4eb99d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _____________________ TestCollectionClient.test_get_items ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5153770>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7fb9e50a5910>
>
> @pytest.mark.vcr
> def test_get_items(self) -> None:
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:21:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5153770>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________________ TestCollectionClient.test_get_items_with_ids _________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e510b380>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7fb9e50a5250>
>
> @pytest.mark.vcr
> def test_get_items_with_ids(self) -> None:
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:30:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e510b380>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestCollectionClient.test_get_item ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e515e900>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7fb9e50a4a70>
>
> @pytest.mark.vcr
> def test_get_item(self) -> None:
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:44:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e515e900>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _____________ TestCollectionClient.test_get_item_with_item_search ______________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e515f200>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7fb9e50a6000>
>
> @pytest.mark.vcr
> def test_get_item_with_item_search(self) -> None:
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:56:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e515f200>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ___________________ TestCollectionClient.test_get_queryables ___________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4ecc800>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7fb9e50a6300>
>
> @pytest.mark.vcr
> def test_get_queryables(self) -> None:
> > api = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:82:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4ecc800>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________________________ TestItemSearch.test_results __________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e505ac30>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f22c60>
>
> @pytest.mark.vcr
> def test_results(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> collections="naip",
> max_items=20,
> limit=10,
> )
> results = search.items()
>
> > assert all(isinstance(item, pystac.Item) for item in results)
>
> tests/test_item_search.py:554:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> tests/test_item_search.py:554: in <genexpr>
> assert all(isinstance(item, pystac.Item) for item in results)
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e505ac30>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _______________________ TestItemSearch.test_ids_results ________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e505b3e0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'ids': ('S2B_MSIL2A_20210610T115639_N0212_R066_T33XXG_20210613T185024.SAFE', 'fl_m_2608004_nw_17_060_20191215_20200113')}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f21910>
>
> @pytest.mark.vcr
> def test_ids_results(self) -> None:
> ids = [
> "S2B_MSIL2A_20210610T115639_N0212_R066_T33XXG_20210613T185024.SAFE",
> "fl_m_2608004_nw_17_060_20191215_20200113",
> ]
> search = ItemSearch(
> url=SEARCH_URL,
> ids=ids,
> )
> > results = list(search.items())
>
> tests/test_item_search.py:566:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e505b3e0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'ids': ('S2B_MSIL2A_20210610T115639_N0212_R066_T33XXG_20210613T185024.SAFE', 'fl_m_2608004_nw_17_060_20191215_20200113')}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _____________________ TestItemSearch.test_datetime_results _____________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5150b00>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'datetime': '2019-01-01T00:00:01Z/2019-01-01T00:00:10Z'}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f20a10>
>
> @pytest.mark.vcr
> def test_datetime_results(self) -> None:
> min_datetime = datetime(2019, 1, 1, 0, 0, 1, tzinfo=tzutc())
> max_datetime = datetime(2019, 1, 1, 0, 0, 10, tzinfo=tzutc())
> datetime_ = "2019-01-01T00:00:01Z/2019-01-01T00:00:10Z"
> search = ItemSearch(url=SEARCH_URL, datetime=datetime_, max_items=20)
> > for item in search.items():
>
> tests/test_item_search.py:577:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5150b00>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'datetime': '2019-01-01T00:00:01Z/2019-01-01T00:00:10Z'}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____________________ TestItemSearch.test_intersects_results ____________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5151e20>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'intersects': {'coordinates': [[[-73.21, 43.99], [-73.21, 44.05], [-73.12, 44.05], [-73.12, 43.99], [-73.21, 43.99]]], 'type': 'Polygon'}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f21940>
>
> @pytest.mark.vcr
> def test_intersects_results(self) -> None:
> # GeoJSON-like dict
> intersects_dict = {
> "type": "Polygon",
> "coordinates": [
> [
> [-73.21, 43.99],
> [-73.21, 44.05],
> [-73.12, 44.05],
> [-73.12, 43.99],
> [-73.21, 43.99],
> ]
> ],
> }
> search = ItemSearch(
> url=SEARCH_URL, intersects=intersects_dict, collections="naip"
> )
> > results = list(search.items())
>
> tests/test_item_search.py:610:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5151e20>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'intersects': {'coordinates': [[[-73.21, 43.99], [-73.21, 44.05], [-73.12, 44.05], [-73.12, 43.99], [-73.21, 43.99]]], 'type': 'Polygon'}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestItemSearch.test_result_paging _______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e50c4f80>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f233b0>
>
> @pytest.mark.vcr
> def test_result_paging(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> # Check that the current page changes on the ItemSearch instance when a new page
> # is requested
> > pages = list(search.pages())
>
> tests/test_item_search.py:655:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:721: in pages
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e50c4f80>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________________ TestItemSearch.test_result_paging_max_items __________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e50c5d60>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f23680>
>
> @pytest.mark.vcr
> def test_result_paging_max_items(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> collections="naip",
> limit=10,
> max_items=25,
> )
> num_pages = 0
> items = list()
> > for page in search.pages_as_dicts():
>
> tests/test_item_search.py:670:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e50c5d60>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _____________________ TestItemSearch.test_item_collection ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e510a270>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f239b0>
>
> @pytest.mark.vcr
> def test_item_collection(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
> > item_collection = search.item_collection()
>
> tests/test_item_search.py:685:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:766: in item_collection
> feature_collection = self.item_collection_as_dict.__wrapped__(self)
> pystac_client/item_search.py:787: in item_collection_as_dict
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e510a270>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____ TestItemSearch.test_deprecations[get_item_collections-pages-True-True] ____
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4e73c20>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f23dd0>
> method = 'get_item_collections', alternative = 'pages', is_sequence = True
> is_pystac = True
>
> @pytest.mark.vcr
> @pytest.mark.parametrize(
> "method, alternative, is_sequence, is_pystac",
> [
> ("get_item_collections", "pages", True, True),
> ("item_collections", "pages", True, True),
> ("get_items", "items", True, True),
> ("get_all_items", "item_collection", False, True),
> ("get_all_items_as_dict", "item_collection_as_dict", False, False),
> ],
> )
> def test_deprecations(
> self, method: str, alternative: str, is_sequence: bool, is_pystac: bool
> ) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> with pytest.warns(FutureWarning, match=method):
> result = operator.methodcaller(method)(search)
>
> expected = operator.methodcaller(alternative)(search)
>
> if is_sequence:
> > result = list(result)
>
> tests/test_item_search.py:717:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:721: in pages
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4e73c20>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______ TestItemSearch.test_deprecations[item_collections-pages-True-True] ______
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4e71310>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f01010>
> method = 'item_collections', alternative = 'pages', is_sequence = True
> is_pystac = True
>
> @pytest.mark.vcr
> @pytest.mark.parametrize(
> "method, alternative, is_sequence, is_pystac",
> [
> ("get_item_collections", "pages", True, True),
> ("item_collections", "pages", True, True),
> ("get_items", "items", True, True),
> ("get_all_items", "item_collection", False, True),
> ("get_all_items_as_dict", "item_collection_as_dict", False, False),
> ],
> )
> def test_deprecations(
> self, method: str, alternative: str, is_sequence: bool, is_pystac: bool
> ) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> with pytest.warns(FutureWarning, match=method):
> result = operator.methodcaller(method)(search)
>
> expected = operator.methodcaller(alternative)(search)
>
> if is_sequence:
> > result = list(result)
>
> tests/test_item_search.py:717:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:721: in pages
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4e71310>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________ TestItemSearch.test_deprecations[get_items-items-True-True] __________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e510bb60>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f02c30>
> method = 'get_items', alternative = 'items', is_sequence = True
> is_pystac = True
>
> @pytest.mark.vcr
> @pytest.mark.parametrize(
> "method, alternative, is_sequence, is_pystac",
> [
> ("get_item_collections", "pages", True, True),
> ("item_collections", "pages", True, True),
> ("get_items", "items", True, True),
> ("get_all_items", "item_collection", False, True),
> ("get_all_items_as_dict", "item_collection_as_dict", False, False),
> ],
> )
> def test_deprecations(
> self, method: str, alternative: str, is_sequence: bool, is_pystac: bool
> ) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> with pytest.warns(FutureWarning, match=method):
> result = operator.methodcaller(method)(search)
>
> expected = operator.methodcaller(alternative)(search)
>
> if is_sequence:
> > result = list(result)
>
> tests/test_item_search.py:717:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e510bb60>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> __ TestItemSearch.test_deprecations[get_all_items-item_collection-False-True] __
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e510a3c0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f037a0>
> method = 'get_all_items', alternative = 'item_collection', is_sequence = False
> is_pystac = True
>
> @pytest.mark.vcr
> @pytest.mark.parametrize(
> "method, alternative, is_sequence, is_pystac",
> [
> ("get_item_collections", "pages", True, True),
> ("item_collections", "pages", True, True),
> ("get_items", "items", True, True),
> ("get_all_items", "item_collection", False, True),
> ("get_all_items_as_dict", "item_collection_as_dict", False, False),
> ],
> )
> def test_deprecations(
> self, method: str, alternative: str, is_sequence: bool, is_pystac: bool
> ) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> with pytest.warns(FutureWarning, match=method):
> > result = operator.methodcaller(method)(search)
>
> tests/test_item_search.py:712:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:855: in get_all_items
> return self.item_collection()
> pystac_client/item_search.py:766: in item_collection
> feature_collection = self.item_collection_as_dict.__wrapped__(self)
> pystac_client/item_search.py:787: in item_collection_as_dict
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e510a3c0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _ TestItemSearch.test_deprecations[get_all_items_as_dict-item_collection_as_dict-False-False] _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5093f80>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f03aa0>
> method = 'get_all_items_as_dict', alternative = 'item_collection_as_dict'
> is_sequence = False, is_pystac = False
>
> @pytest.mark.vcr
> @pytest.mark.parametrize(
> "method, alternative, is_sequence, is_pystac",
> [
> ("get_item_collections", "pages", True, True),
> ("item_collections", "pages", True, True),
> ("get_items", "items", True, True),
> ("get_all_items", "item_collection", False, True),
> ("get_all_items_as_dict", "item_collection_as_dict", False, False),
> ],
> )
> def test_deprecations(
> self, method: str, alternative: str, is_sequence: bool, is_pystac: bool
> ) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> with pytest.warns(FutureWarning, match=method):
> > result = operator.methodcaller(method)(search)
>
> tests/test_item_search.py:712:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:871: in get_all_items_as_dict
> return self.item_collection_as_dict()
> pystac_client/item_search.py:787: in item_collection_as_dict
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e5093f80>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestItemSearch.test_items_as_dicts ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e50929c0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7fb9e4f002c0>
>
> @pytest.mark.vcr
> def test_items_as_dicts(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
> > assert len(list(search.items_as_dicts())) == 20
>
> tests/test_item_search.py:738:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e50929c0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ________________ TestItemSearchQuery.test_query_shortcut_syntax ________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4e73860>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'query': {'gsd': {'eq': 0.6}}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearchQuery object at 0x7fb9e4f00620>
>
> @pytest.mark.vcr
> def test_query_shortcut_syntax(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> collections="naip",
> bbox=(-73.21, 43.99, -73.12, 44.05),
> query=["gsd=0.6"],
> max_items=1,
> )
> > items1 = list(search.items())
>
> tests/test_item_search.py:751:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4e73860>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'query': {'gsd': {'eq': 0.6}}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> __________________ TestItemSearchQuery.test_query_json_syntax __________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e50c5d90>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'query': {'gsd': {'gte': 0, 'lte': 1}}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearchQuery object at 0x7fb9e4f008f0>
>
> @pytest.mark.vcr
> def test_query_json_syntax(self) -> None:
> # with a list of json strs (format of CLI argument to ItemSearch)
> search = ItemSearch(
> url=SEARCH_URL,
> collections="naip",
> bbox=(-73.21, 43.99, -73.12, 44.05),
> query=['{"gsd": { "gte": 0, "lte": 1 }}'],
> max_items=1,
> )
> > item1 = list(search.items())[0]
>
> tests/test_item_search.py:776:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e50c5d90>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'query': {'gsd': {'gte': 0, 'lte': 1}}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____________________ TestSTAC_IOOverride.test_request_input ____________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4db6000>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_stac_api_io.TestSTAC_IOOverride object at 0x7fb9e4f23500>
>
> @pytest.mark.vcr
> def test_request_input(self) -> None:
> stac_api_io = StacApiIO()
> > response = stac_api_io.read_text(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_stac_api_io.py:19:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e4db6000>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestSTAC_IOOverride.test_str_input ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e50911f0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_stac_api_io.TestSTAC_IOOverride object at 0x7fb9e4f01820>
>
> @pytest.mark.vcr
> def test_str_input(self) -> None:
> stac_api_io = StacApiIO()
> > response = stac_api_io.read_text(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_stac_api_io.py:25:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e50911f0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________________ TestSTAC_IOOverride.test_timeout_smoke_test __________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e515f980>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_stac_api_io.TestSTAC_IOOverride object at 0x7fb9e4f03710>
>
> @pytest.mark.vcr
> def test_timeout_smoke_test(self) -> None:
> # Testing timeout behavior is hard, so we just have a simple smoke test to make
> # sure that providing a timeout doesn't break anything.
> stac_api_io = StacApiIO(timeout=42)
> > response = stac_api_io.read_text(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_stac_api_io.py:268:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7fb9e515f980>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> =========================== short test summary info ============================
> FAILED tests/test_cli.py::TestCLISearch::test_item_search[inprocess] - assert...
> FAILED tests/test_cli.py::TestCLISearch::test_intersects[inprocess-netherlands_aoi.json]
> FAILED tests/test_cli.py::TestCLISearch::test_intersects[inprocess-sample-item.json]
> FAILED tests/test_cli.py::TestCLISearch::test_intersects_despite_warning[inprocess]
> FAILED tests/test_cli.py::TestCLISearch::test_matched_not_available[inprocess]
> FAILED tests/test_client.py::TestAPI::test_instance - pystac_client.exception...
> FAILED tests/test_client.py::TestAPI::test_links - pystac_client.exceptions.A...
> FAILED tests/test_client.py::TestAPI::test_from_file - pystac_client.exceptio...
> FAILED tests/test_client.py::TestAPISearch::test_search_max_items_unlimited_default
> FAILED tests/test_client.py::TestSigning::test_signing - pystac_client.except...
> FAILED tests/test_client.py::TestSigning::test_sign_with_return_warns - pysta...
> FAILED tests/test_client.py::TestQueryables::test_get_queryables - pystac_cli...
> FAILED tests/test_client.py::TestQueryables::test_get_queryables_collections
> FAILED tests/test_client.py::test_collections_are_clients - pystac_client.exc...
> FAILED tests/test_client.py::test_get_items_without_ids - pystac_client.excep...
> FAILED tests/test_client.py::test_non_recursion_on_fallback - pystac_client.e...
> FAILED tests/test_client.py::test_fallback_strategy - pystac_client.exception...
> FAILED tests/test_collection_client.py::TestCollectionClient::test_instance
> FAILED tests/test_collection_client.py::TestCollectionClient::test_get_items
> FAILED tests/test_collection_client.py::TestCollectionClient::test_get_items_with_ids
> FAILED tests/test_collection_client.py::TestCollectionClient::test_get_item
> FAILED tests/test_collection_client.py::TestCollectionClient::test_get_item_with_item_search
> FAILED tests/test_collection_client.py::TestCollectionClient::test_get_queryables
> FAILED tests/test_item_search.py::TestItemSearch::test_results - pystac_clien...
> FAILED tests/test_item_search.py::TestItemSearch::test_ids_results - pystac_c...
> FAILED tests/test_item_search.py::TestItemSearch::test_datetime_results - pys...
> FAILED tests/test_item_search.py::TestItemSearch::test_intersects_results - p...
> FAILED tests/test_item_search.py::TestItemSearch::test_result_paging - pystac...
> FAILED tests/test_item_search.py::TestItemSearch::test_result_paging_max_items
> FAILED tests/test_item_search.py::TestItemSearch::test_item_collection - pyst...
> FAILED tests/test_item_search.py::TestItemSearch::test_deprecations[get_item_collections-pages-True-True]
> FAILED tests/test_item_search.py::TestItemSearch::test_deprecations[item_collections-pages-True-True]
> FAILED tests/test_item_search.py::TestItemSearch::test_deprecations[get_items-items-True-True]
> FAILED tests/test_item_search.py::TestItemSearch::test_deprecations[get_all_items-item_collection-False-True]
> FAILED tests/test_item_search.py::TestItemSearch::test_deprecations[get_all_items_as_dict-item_collection_as_dict-False-False]
> FAILED tests/test_item_search.py::TestItemSearch::test_items_as_dicts - pysta...
> FAILED tests/test_item_search.py::TestItemSearchQuery::test_query_shortcut_syntax
> FAILED tests/test_item_search.py::TestItemSearchQuery::test_query_json_syntax
> FAILED tests/test_stac_api_io.py::TestSTAC_IOOverride::test_request_input - p...
> FAILED tests/test_stac_api_io.py::TestSTAC_IOOverride::test_str_input - pysta...
> FAILED tests/test_stac_api_io.py::TestSTAC_IOOverride::test_timeout_smoke_test
> =========== 41 failed, 114 passed, 3 skipped, 1 deselected in 3.18s ============
> E: pybuild pybuild:389: test: plugin pyproject failed with: exit code=1: cd /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build; python3.12 -m pytest -k "not test_localized_datetime_converted_to_utc" --block-network
> I: pybuild base:311: cd /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build; python3.11 -m pytest -k "not test_localized_datetime_converted_to_utc" --block-network
> ============================= test session starts ==============================
> platform linux -- Python 3.11.9, pytest-8.2.2, pluggy-1.5.0
> benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
> rootdir: /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build
> configfile: pyproject.toml
> plugins: requests-mock-1.11.0, console-scripts-1.4.1, recording-0.13.1, benchmark-4.0.0
> collected 159 items / 1 deselected / 158 selected
>
> tests/test_cli.py F.FFF...............F.... [ 15%]
> tests/test_client.py FFF..................FFFFF........FFFF [ 39%]
> tests/test_collection_client.py FFFFFF [ 43%]
> tests/test_item_search.py sss........................................... [ 72%]
> ..FFFF.FFFFFFFFFFF...... [ 87%]
> tests/test_stac_api_io.py FF..............F.. [100%]
>
> =================================== FAILURES ===================================
> __________________ TestCLISearch.test_item_search[inprocess] ___________________
>
> self = <tests.test_cli.TestCLISearch object at 0x7f91ac5ff850>
> script_runner = <ScriptRunner inprocess>
>
> @pytest.mark.vcr
> def test_item_search(self, script_runner: ScriptRunner) -> None:
> args = [
> "stac-client",
> "search",
> STAC_URLS["PLANETARY-COMPUTER"],
> "-c",
> "naip",
> "--max-items",
> "20",
> ]
> result = script_runner.run(args, print_result=False)
> > assert result.success
> E assert False
> E + where False = <pytest_console_scripts.RunResult object at 0x7f91ac2da890>.success
>
> tests/test_cli.py:29: AssertionError
> ________ TestCLISearch.test_intersects[inprocess-netherlands_aoi.json] _________
>
> self = <tests.test_cli.TestCLISearch object at 0x7f91ac0283d0>
> script_runner = <ScriptRunner inprocess>, filename = 'netherlands_aoi.json'
>
> @pytest.mark.vcr
> @pytest.mark.parametrize("filename", ["netherlands_aoi.json", "sample-item.json"])
> def test_intersects(self, script_runner: ScriptRunner, filename: str) -> None:
> args = [
> "stac-client",
> "search",
> STAC_URLS["PLANETARY-COMPUTER"],
> "--collections",
> "landsat-8-c2-l2",
> "--intersects",
> str(TEST_DATA / filename),
> "--max-items",
> "10",
> ]
> result = script_runner.run(args, print_result=False)
> > assert result.success, result.stderr
> E AssertionError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E Traceback (most recent call last):
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/stac_api_io.py", line 222, in request
> E return resp.content.decode("utf-8")
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E
> E During handling of the above exception, another exception occurred:
> E
> E Traceback (most recent call last):
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/cli.py", line 349, in cli
> E client = Client.open(url, headers=headers)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/client.py", line 169, in open
> E client: Client = cls.from_file(
> E ^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/client.py", line 225, in from_file
> E client: Client = super().from_file(href, stac_io)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/catalog.py", line 1273, in from_file
> E result = super().from_file(href, stac_io)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/stac_object.py", line 629, in from_file
> E d = stac_io.read_json(href)
> E ^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/stac_io.py", line 205, in read_json
> E txt = self.read_text(source, *args, **kwargs)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/stac_api_io.py", line 168, in read_text
> E return self.request(href, *args, **kwargs)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/stac_api_io.py", line 224, in request
> E raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E
> E assert False
> E + where False = <pytest_console_scripts.RunResult object at 0x7f91abd64a90>.success
>
> tests/test_cli.py:61: AssertionError
> __________ TestCLISearch.test_intersects[inprocess-sample-item.json] ___________
>
> self = <tests.test_cli.TestCLISearch object at 0x7f91ac028610>
> script_runner = <ScriptRunner inprocess>, filename = 'sample-item.json'
>
> @pytest.mark.vcr
> @pytest.mark.parametrize("filename", ["netherlands_aoi.json", "sample-item.json"])
> def test_intersects(self, script_runner: ScriptRunner, filename: str) -> None:
> args = [
> "stac-client",
> "search",
> STAC_URLS["PLANETARY-COMPUTER"],
> "--collections",
> "landsat-8-c2-l2",
> "--intersects",
> str(TEST_DATA / filename),
> "--max-items",
> "10",
> ]
> result = script_runner.run(args, print_result=False)
> > assert result.success, result.stderr
> E AssertionError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E Traceback (most recent call last):
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/stac_api_io.py", line 222, in request
> E return resp.content.decode("utf-8")
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E
> E During handling of the above exception, another exception occurred:
> E
> E Traceback (most recent call last):
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/cli.py", line 349, in cli
> E client = Client.open(url, headers=headers)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/client.py", line 169, in open
> E client: Client = cls.from_file(
> E ^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/client.py", line 225, in from_file
> E client: Client = super().from_file(href, stac_io)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/catalog.py", line 1273, in from_file
> E result = super().from_file(href, stac_io)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/stac_object.py", line 629, in from_file
> E d = stac_io.read_json(href)
> E ^^^^^^^^^^^^^^^^^^^^^^^
> E File "/usr/lib/python3/dist-packages/pystac/stac_io.py", line 205, in read_json
> E txt = self.read_text(source, *args, **kwargs)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/stac_api_io.py", line 168, in read_text
> E return self.request(href, *args, **kwargs)
> E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> E File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build/pystac_client/stac_api_io.py", line 224, in request
> E raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
> E
> E assert False
> E + where False = <pytest_console_scripts.RunResult object at 0x7f91abe905d0>.success
>
> tests/test_cli.py:61: AssertionError
> ___________ TestCLISearch.test_intersects_despite_warning[inprocess] ___________
>
> self = <tests.test_cli.TestCLISearch object at 0x7f91ac028e50>
> script_runner = <ScriptRunner inprocess>
>
> @pytest.mark.vcr
> def test_intersects_despite_warning(self, script_runner: ScriptRunner) -> None:
> args = [
> "stac-client",
> "search",
> STAC_URLS["PLANETARY-COMPUTER"],
> "--collections",
> "landsat-8-c2-l2",
> "--intersects",
> str(TEST_DATA / "sample-item-collection.json"),
> "--max-items",
> "10",
> ]
> result = script_runner.run(args, print_result=False)
> > assert result.success
> E assert False
> E + where False = <pytest_console_scripts.RunResult object at 0x7f91abd0abd0>.success
>
> tests/test_cli.py:78: AssertionError
> _____________ TestCLISearch.test_matched_not_available[inprocess] ______________
>
> self = <tests.test_cli.TestCLISearch object at 0x7f91ac00ec10>
> script_runner = <ScriptRunner inprocess>
>
> @pytest.mark.vcr
> @pytest.mark.filterwarnings("ignore::Warning")
> def test_matched_not_available(self, script_runner: ScriptRunner) -> None:
> args = [
> "stac-client",
> "search",
> STAC_URLS["PLANETARY-COMPUTER"],
> "-c",
> "naip",
> "--matched",
> ]
> result = script_runner.run(args, print_result=False)
> assert result.success is False
> > assert "'matched' is not supported for this catalog" in result.stderr
> E assert "'matched' is not supported for this catalog" in "INFO:vcr.stubs:Playing response for <Request (GET) https://planetarycomputer.microsoft.com/api/stac/v1> from cassette...str(err))\npystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte\n"
> E + where "INFO:vcr.stubs:Playing response for <Request (GET) https://planetarycomputer.microsoft.com/api/stac/v1> from cassette...str(err))\npystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte\n" = <pytest_console_scripts.RunResult object at 0x7f91ac004690>.stderr
>
> tests/test_cli.py:211: AssertionError
> ____________________________ TestAPI.test_instance _____________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abd6dcd0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestAPI object at 0x7f91abd66850>
>
> @pytest.mark.vcr
> def test_instance(self) -> None:
> > api = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_client.py:35:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abd6dcd0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________________ TestAPI.test_links ______________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9f71d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestAPI object at 0x7f91abd66f10>
>
> @pytest.mark.vcr
> def test_links(self) -> None:
> > api = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_client.py:44:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9f71d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____________________________ TestAPI.test_from_file ____________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91aba93250>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestAPI object at 0x7f91abd67450>
>
> @pytest.mark.vcr
> def test_from_file(self) -> None:
> > api = Client.from_file(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_client.py:60:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91aba93250>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____________ TestAPISearch.test_search_max_items_unlimited_default _____________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abf70690>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 45.05), 'collections': ('naip',), 'datetime': '2014-01-01T00:00:00Z/2020-12-31T23:59:59Z'}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestAPISearch object at 0x7f91abd5abd0>
> api = <Client id=microsoft-pc>
>
> @pytest.mark.vcr
> def test_search_max_items_unlimited_default(self, api: Client) -> None:
> search = api.search(
> bbox=[-73.21, 43.99, -73.12, 45.05],
> collections="naip",
> datetime="2014-01-01/2020-12-31",
> )
> > items = list(search.items())
>
> tests/test_client.py:503:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abf70690>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 45.05), 'collections': ('naip',), 'datetime': '2014-01-01T00:00:00Z/2020-12-31T23:59:59Z'}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ___________________________ TestSigning.test_signing ___________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abde2e90>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestSigning object at 0x7f91abd5aed0>
>
> @pytest.mark.vcr
> def test_signing(self) -> None:
> sign = MySign()
> # sign is callable, but mypy keeps trying to interpret it as a "MySign" object.
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"], modifier=sign)
>
> tests/test_client.py:520:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abde2e90>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ___________________ TestSigning.test_sign_with_return_warns ____________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abdb7090>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestSigning object at 0x7f91abd5b4d0>
>
> @pytest.mark.vcr
> def test_sign_with_return_warns(self) -> None:
> def modifier_ok(x: Any) -> Any:
> return x
>
> def modifier_bad(x: Any) -> Any:
> return 0
>
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"], modifier=modifier_ok)
>
> tests/test_client.py:568:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abdb7090>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestQueryables.test_get_queryables ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abba6790>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestQueryables object at 0x7f91abd5bd50>
>
> @pytest.mark.vcr
> def test_get_queryables(self) -> None:
> > api = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_client.py:581:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abba6790>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ________________ TestQueryables.test_get_queryables_collections ________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9d8a50>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_client.TestQueryables object at 0x7f91abd58890>
>
> @pytest.mark.vcr
> def test_get_queryables_collections(self) -> None:
> > api = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_client.py:589:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9d8a50>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________________________ test_collections_are_clients _________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abd469d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> @pytest.mark.vcr
> def test_collections_are_clients() -> None:
> # https://github.com/stac-utils/pystac-client/issues/548
> > catalog = Client.open(
> "https://planetarycomputer.microsoft.com/api/stac/v1/",
> )
>
> tests/test_client.py:691:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abd469d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> __________________________ test_get_items_without_ids __________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9a02d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> @pytest.mark.vcr
> def test_get_items_without_ids() -> None:
> > client = Client.open(
> "https://planetarycomputer.microsoft.com/api/stac/v1/",
> )
>
> tests/test_client.py:703:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9a02d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ________________________ test_non_recursion_on_fallback ________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abcd1f10>
> href = 'https://raw.githubusercontent.com/stac-utils/pystac/v1.9.0/docs/example-catalog/catalog.json'
> method = None, headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> @pytest.mark.vcr
> def test_non_recursion_on_fallback() -> None:
> path = "https://raw.githubusercontent.com/stac-utils/pystac/v1.9.0/docs/example-catalog/catalog.json"
> > catalog = Client.from_file(path)
>
> tests/test_client.py:712:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abcd1f10>
> href = 'https://raw.githubusercontent.com/stac-utils/pystac/v1.9.0/docs/example-catalog/catalog.json'
> method = None, headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____________________________ test_fallback_strategy ____________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abd49f10>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> @pytest.mark.vcr
> def test_fallback_strategy() -> None:
> """Make sure links get recreated correctly using APILayoutStrategy."""
>
> > client = Client.open(
> "https://planetarycomputer.microsoft.com/api/stac/v1/",
> )
>
> tests/test_client.py:721:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abd49f10>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestCollectionClient.test_instance ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abda89d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7f91abcb63d0>
>
> @pytest.mark.vcr
> def test_instance(self) -> None:
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:13:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abda89d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _____________________ TestCollectionClient.test_get_items ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abe2af90>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7f91abcb6b10>
>
> @pytest.mark.vcr
> def test_get_items(self) -> None:
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:21:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abe2af90>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________________ TestCollectionClient.test_get_items_with_ids _________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab993990>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7f91abcb6c90>
>
> @pytest.mark.vcr
> def test_get_items_with_ids(self) -> None:
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:30:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab993990>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestCollectionClient.test_get_item ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abf70810>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7f91abcb61d0>
>
> @pytest.mark.vcr
> def test_get_item(self) -> None:
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:44:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abf70810>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _____________ TestCollectionClient.test_get_item_with_item_search ______________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab8b51d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7f91abcb7550>
>
> @pytest.mark.vcr
> def test_get_item_with_item_search(self) -> None:
> > client = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:56:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab8b51d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ___________________ TestCollectionClient.test_get_queryables ___________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abc54dd0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_collection_client.TestCollectionClient object at 0x7f91abcb7dd0>
>
> @pytest.mark.vcr
> def test_get_queryables(self) -> None:
> > api = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_collection_client.py:82:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/client.py:169: in open
> client: Client = cls.from_file(
> pystac_client/client.py:225: in from_file
> client: Client = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/catalog.py:1273: in from_file
> result = super().from_file(href, stac_io)
> /usr/lib/python3/dist-packages/pystac/stac_object.py:629: in from_file
> d = stac_io.read_json(href)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abc54dd0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________________________ TestItemSearch.test_results __________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abc42a50>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abf524d0>
>
> @pytest.mark.vcr
> def test_results(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> collections="naip",
> max_items=20,
> limit=10,
> )
> results = search.items()
>
> > assert all(isinstance(item, pystac.Item) for item in results)
>
> tests/test_item_search.py:554:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> tests/test_item_search.py:554: in <genexpr>
> assert all(isinstance(item, pystac.Item) for item in results)
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abc42a50>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _______________________ TestItemSearch.test_ids_results ________________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abc34610>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'ids': ('S2B_MSIL2A_20210610T115639_N0212_R066_T33XXG_20210613T185024.SAFE', 'fl_m_2608004_nw_17_060_20191215_20200113')}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc6c0d0>
>
> @pytest.mark.vcr
> def test_ids_results(self) -> None:
> ids = [
> "S2B_MSIL2A_20210610T115639_N0212_R066_T33XXG_20210613T185024.SAFE",
> "fl_m_2608004_nw_17_060_20191215_20200113",
> ]
> search = ItemSearch(
> url=SEARCH_URL,
> ids=ids,
> )
> > results = list(search.items())
>
> tests/test_item_search.py:566:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abc34610>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'ids': ('S2B_MSIL2A_20210610T115639_N0212_R066_T33XXG_20210613T185024.SAFE', 'fl_m_2608004_nw_17_060_20191215_20200113')}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _____________________ TestItemSearch.test_datetime_results _____________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9d9b10>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'datetime': '2019-01-01T00:00:01Z/2019-01-01T00:00:10Z'}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc6dfd0>
>
> @pytest.mark.vcr
> def test_datetime_results(self) -> None:
> min_datetime = datetime(2019, 1, 1, 0, 0, 1, tzinfo=tzutc())
> max_datetime = datetime(2019, 1, 1, 0, 0, 10, tzinfo=tzutc())
> datetime_ = "2019-01-01T00:00:01Z/2019-01-01T00:00:10Z"
> search = ItemSearch(url=SEARCH_URL, datetime=datetime_, max_items=20)
> > for item in search.items():
>
> tests/test_item_search.py:577:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9d9b10>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'datetime': '2019-01-01T00:00:01Z/2019-01-01T00:00:10Z'}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____________________ TestItemSearch.test_intersects_results ____________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9a2b50>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'intersects': {'coordinates': [[[-73.21, 43.99], [-73.21, 44.05], [-73.12, 44.05], [-73.12, 43.99], [-73.21, 43.99]]], 'type': 'Polygon'}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc6f090>
>
> @pytest.mark.vcr
> def test_intersects_results(self) -> None:
> # GeoJSON-like dict
> intersects_dict = {
> "type": "Polygon",
> "coordinates": [
> [
> [-73.21, 43.99],
> [-73.21, 44.05],
> [-73.12, 44.05],
> [-73.12, 43.99],
> [-73.21, 43.99],
> ]
> ],
> }
> search = ItemSearch(
> url=SEARCH_URL, intersects=intersects_dict, collections="naip"
> )
> > results = list(search.items())
>
> tests/test_item_search.py:610:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9a2b50>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'intersects': {'coordinates': [[[-73.21, 43.99], [-73.21, 44.05], [-73.12, 44.05], [-73.12, 43.99], [-73.21, 43.99]]], 'type': 'Polygon'}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestItemSearch.test_result_paging _______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abd6ced0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc63ed0>
>
> @pytest.mark.vcr
> def test_result_paging(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> # Check that the current page changes on the ItemSearch instance when a new page
> # is requested
> > pages = list(search.pages())
>
> tests/test_item_search.py:655:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:721: in pages
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abd6ced0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________________ TestItemSearch.test_result_paging_max_items __________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91aba49e90>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc63f90>
>
> @pytest.mark.vcr
> def test_result_paging_max_items(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> collections="naip",
> limit=10,
> max_items=25,
> )
> num_pages = 0
> items = list()
> > for page in search.pages_as_dicts():
>
> tests/test_item_search.py:670:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91aba49e90>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _____________________ TestItemSearch.test_item_collection ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abb63350>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc627d0>
>
> @pytest.mark.vcr
> def test_item_collection(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
> > item_collection = search.item_collection()
>
> tests/test_item_search.py:685:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:766: in item_collection
> feature_collection = self.item_collection_as_dict.__wrapped__(self)
> pystac_client/item_search.py:787: in item_collection_as_dict
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abb63350>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____ TestItemSearch.test_deprecations[get_item_collections-pages-True-True] ____
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abc2bf10>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc63210>
> method = 'get_item_collections', alternative = 'pages', is_sequence = True
> is_pystac = True
>
> @pytest.mark.vcr
> @pytest.mark.parametrize(
> "method, alternative, is_sequence, is_pystac",
> [
> ("get_item_collections", "pages", True, True),
> ("item_collections", "pages", True, True),
> ("get_items", "items", True, True),
> ("get_all_items", "item_collection", False, True),
> ("get_all_items_as_dict", "item_collection_as_dict", False, False),
> ],
> )
> def test_deprecations(
> self, method: str, alternative: str, is_sequence: bool, is_pystac: bool
> ) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> with pytest.warns(FutureWarning, match=method):
> result = operator.methodcaller(method)(search)
>
> expected = operator.methodcaller(alternative)(search)
>
> if is_sequence:
> > result = list(result)
>
> tests/test_item_search.py:717:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:721: in pages
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abc2bf10>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______ TestItemSearch.test_deprecations[item_collections-pages-True-True] ______
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abc42110>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc63650>
> method = 'item_collections', alternative = 'pages', is_sequence = True
> is_pystac = True
>
> @pytest.mark.vcr
> @pytest.mark.parametrize(
> "method, alternative, is_sequence, is_pystac",
> [
> ("get_item_collections", "pages", True, True),
> ("item_collections", "pages", True, True),
> ("get_items", "items", True, True),
> ("get_all_items", "item_collection", False, True),
> ("get_all_items_as_dict", "item_collection_as_dict", False, False),
> ],
> )
> def test_deprecations(
> self, method: str, alternative: str, is_sequence: bool, is_pystac: bool
> ) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> with pytest.warns(FutureWarning, match=method):
> result = operator.methodcaller(method)(search)
>
> expected = operator.methodcaller(alternative)(search)
>
> if is_sequence:
> > result = list(result)
>
> tests/test_item_search.py:717:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:721: in pages
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abc42110>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________ TestItemSearch.test_deprecations[get_items-items-True-True] __________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abdb6b90>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc63810>
> method = 'get_items', alternative = 'items', is_sequence = True
> is_pystac = True
>
> @pytest.mark.vcr
> @pytest.mark.parametrize(
> "method, alternative, is_sequence, is_pystac",
> [
> ("get_item_collections", "pages", True, True),
> ("item_collections", "pages", True, True),
> ("get_items", "items", True, True),
> ("get_all_items", "item_collection", False, True),
> ("get_all_items_as_dict", "item_collection_as_dict", False, False),
> ],
> )
> def test_deprecations(
> self, method: str, alternative: str, is_sequence: bool, is_pystac: bool
> ) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> with pytest.warns(FutureWarning, match=method):
> result = operator.methodcaller(method)(search)
>
> expected = operator.methodcaller(alternative)(search)
>
> if is_sequence:
> > result = list(result)
>
> tests/test_item_search.py:717:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abdb6b90>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> __ TestItemSearch.test_deprecations[get_all_items-item_collection-False-True] __
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abad3d50>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc61210>
> method = 'get_all_items', alternative = 'item_collection', is_sequence = False
> is_pystac = True
>
> @pytest.mark.vcr
> @pytest.mark.parametrize(
> "method, alternative, is_sequence, is_pystac",
> [
> ("get_item_collections", "pages", True, True),
> ("item_collections", "pages", True, True),
> ("get_items", "items", True, True),
> ("get_all_items", "item_collection", False, True),
> ("get_all_items_as_dict", "item_collection_as_dict", False, False),
> ],
> )
> def test_deprecations(
> self, method: str, alternative: str, is_sequence: bool, is_pystac: bool
> ) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> with pytest.warns(FutureWarning, match=method):
> > result = operator.methodcaller(method)(search)
>
> tests/test_item_search.py:712:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:855: in get_all_items
> return self.item_collection()
> pystac_client/item_search.py:766: in item_collection
> feature_collection = self.item_collection_as_dict.__wrapped__(self)
> pystac_client/item_search.py:787: in item_collection_as_dict
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abad3d50>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _ TestItemSearch.test_deprecations[get_all_items_as_dict-item_collection_as_dict-False-False] _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abb9a810>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc60fd0>
> method = 'get_all_items_as_dict', alternative = 'item_collection_as_dict'
> is_sequence = False, is_pystac = False
>
> @pytest.mark.vcr
> @pytest.mark.parametrize(
> "method, alternative, is_sequence, is_pystac",
> [
> ("get_item_collections", "pages", True, True),
> ("item_collections", "pages", True, True),
> ("get_items", "items", True, True),
> ("get_all_items", "item_collection", False, True),
> ("get_all_items_as_dict", "item_collection_as_dict", False, False),
> ],
> )
> def test_deprecations(
> self, method: str, alternative: str, is_sequence: bool, is_pystac: bool
> ) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
>
> with pytest.warns(FutureWarning, match=method):
> > result = operator.methodcaller(method)(search)
>
> tests/test_item_search.py:712:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:871: in get_all_items_as_dict
> return self.item_collection_as_dict()
> pystac_client/item_search.py:787: in item_collection_as_dict
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abb9a810>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestItemSearch.test_items_as_dicts ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abe6bcd0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearch object at 0x7f91abc61850>
>
> @pytest.mark.vcr
> def test_items_as_dicts(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> bbox=(-73.21, 43.99, -73.12, 44.05),
> collections="naip",
> limit=10,
> max_items=20,
> )
> > assert len(list(search.items_as_dicts())) == 20
>
> tests/test_item_search.py:738:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abe6bcd0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'limit': 10}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ________________ TestItemSearchQuery.test_query_shortcut_syntax ________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9a8a50>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'query': {'gsd': {'eq': 0.6}}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearchQuery object at 0x7f91abc61d10>
>
> @pytest.mark.vcr
> def test_query_shortcut_syntax(self) -> None:
> search = ItemSearch(
> url=SEARCH_URL,
> collections="naip",
> bbox=(-73.21, 43.99, -73.12, 44.05),
> query=["gsd=0.6"],
> max_items=1,
> )
> > items1 = list(search.items())
>
> tests/test_item_search.py:751:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ab9a8a50>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'query': {'gsd': {'eq': 0.6}}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> __________________ TestItemSearchQuery.test_query_json_syntax __________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abe293d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'query': {'gsd': {'gte': 0, 'lte': 1}}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_item_search.TestItemSearchQuery object at 0x7f91abc602d0>
>
> @pytest.mark.vcr
> def test_query_json_syntax(self) -> None:
> # with a list of json strs (format of CLI argument to ItemSearch)
> search = ItemSearch(
> url=SEARCH_URL,
> collections="naip",
> bbox=(-73.21, 43.99, -73.12, 44.05),
> query=['{"gsd": { "gte": 0, "lte": 1 }}'],
> max_items=1,
> )
> > item1 = list(search.items())[0]
>
> tests/test_item_search.py:776:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/item_search.py:694: in items
> for item in self.items_as_dicts():
> pystac_client/item_search.py:705: in items_as_dicts
> for page in self.pages_as_dicts():
> pystac_client/item_search.py:737: in pages_as_dicts
> for page in self._stac_io.get_pages(
> pystac_client/stac_api_io.py:297: in get_pages
> page = self.read_json(url, method=method, parameters=parameters)
> /usr/lib/python3/dist-packages/pystac/stac_io.py:205: in read_json
> txt = self.read_text(source, *args, **kwargs)
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abe293d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
> method = 'POST', headers = None
> parameters = {'bbox': (-73.21, 43.99, -73.12, 44.05), 'collections': ('naip',), 'query': {'gsd': {'gte': 0, 'lte': 1}}}
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ____________________ TestSTAC_IOOverride.test_request_input ____________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abbc6bd0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_stac_api_io.TestSTAC_IOOverride object at 0x7f91ac06dd10>
>
> @pytest.mark.vcr
> def test_request_input(self) -> None:
> stac_api_io = StacApiIO()
> > response = stac_api_io.read_text(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_stac_api_io.py:19:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91abbc6bd0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> ______________________ TestSTAC_IOOverride.test_str_input ______________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ac4e1d10>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_stac_api_io.TestSTAC_IOOverride object at 0x7f91ac06d990>
>
> @pytest.mark.vcr
> def test_str_input(self) -> None:
> stac_api_io = StacApiIO()
> > response = stac_api_io.read_text(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_stac_api_io.py:25:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91ac4e1d10>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> _________________ TestSTAC_IOOverride.test_timeout_smoke_test __________________
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91aba4b9d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> > return resp.content.decode("utf-8")
> E UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:222: UnicodeDecodeError
>
> During handling of the above exception, another exception occurred:
>
> self = <tests.test_stac_api_io.TestSTAC_IOOverride object at 0x7f91abf73810>
>
> @pytest.mark.vcr
> def test_timeout_smoke_test(self) -> None:
> # Testing timeout behavior is hard, so we just have a simple smoke test to make
> # sure that providing a timeout doesn't break anything.
> stac_api_io = StacApiIO(timeout=42)
> > response = stac_api_io.read_text(STAC_URLS["PLANETARY-COMPUTER"])
>
> tests/test_stac_api_io.py:268:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> pystac_client/stac_api_io.py:168: in read_text
> return self.request(href, *args, **kwargs)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> self = <pystac_client.stac_api_io.StacApiIO object at 0x7f91aba4b9d0>
> href = 'https://planetarycomputer.microsoft.com/api/stac/v1', method = None
> headers = None, parameters = None
>
> def request(
> self,
> href: str,
> method: Optional[str] = None,
> headers: Optional[Dict[str, str]] = None,
> parameters: Optional[Dict[str, Any]] = None,
> ) -> str:
> """Makes a request to an http endpoint
>
> Args:
> href (str): The request URL
> method (Optional[str], optional): The http method to use, 'GET' or 'POST'.
> Defaults to None, which will result in 'GET' being used.
> headers (Optional[Dict[str, str]], optional): Additional headers to include
> in request. Defaults to None.
> parameters (Optional[Dict[str, Any]], optional): parameters to send with
> request. Defaults to None.
>
> Raises:
> APIError: raised if the server returns an error response
>
> Return:
> str: The decoded response from the endpoint
> """
> if method == "POST":
> request = Request(method=method, url=href, headers=headers, json=parameters)
> else:
> params = deepcopy(parameters) or {}
> request = Request(method="GET", url=href, headers=headers, params=params)
> try:
> modified = self._req_modifier(request) if self._req_modifier else None
> prepped = self.session.prepare_request(modified or request)
> msg = f"{prepped.method} {prepped.url} Headers: {prepped.headers}"
> if method == "POST":
> msg += f" Payload: {json.dumps(request.json)}"
> if self.timeout is not None:
> msg += f" Timeout: {self.timeout}"
> logger.debug(msg)
> send_kwargs = self.session.merge_environment_settings(
> prepped.url, proxies={}, stream=None, verify=True, cert=None
> )
> resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
> except Exception as err:
> logger.debug(err)
> raise APIError(str(err))
> if resp.status_code != 200:
> raise APIError.from_response(resp)
> try:
> return resp.content.decode("utf-8")
> except Exception as err:
> > raise APIError(str(err))
> E pystac_client.exceptions.APIError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
>
> pystac_client/stac_api_io.py:224: APIError
> =========================== short test summary info ============================
> FAILED tests/test_cli.py::TestCLISearch::test_item_search[inprocess] - assert...
> FAILED tests/test_cli.py::TestCLISearch::test_intersects[inprocess-netherlands_aoi.json]
> FAILED tests/test_cli.py::TestCLISearch::test_intersects[inprocess-sample-item.json]
> FAILED tests/test_cli.py::TestCLISearch::test_intersects_despite_warning[inprocess]
> FAILED tests/test_cli.py::TestCLISearch::test_matched_not_available[inprocess]
> FAILED tests/test_client.py::TestAPI::test_instance - pystac_client.exception...
> FAILED tests/test_client.py::TestAPI::test_links - pystac_client.exceptions.A...
> FAILED tests/test_client.py::TestAPI::test_from_file - pystac_client.exceptio...
> FAILED tests/test_client.py::TestAPISearch::test_search_max_items_unlimited_default
> FAILED tests/test_client.py::TestSigning::test_signing - pystac_client.except...
> FAILED tests/test_client.py::TestSigning::test_sign_with_return_warns - pysta...
> FAILED tests/test_client.py::TestQueryables::test_get_queryables - pystac_cli...
> FAILED tests/test_client.py::TestQueryables::test_get_queryables_collections
> FAILED tests/test_client.py::test_collections_are_clients - pystac_client.exc...
> FAILED tests/test_client.py::test_get_items_without_ids - pystac_client.excep...
> FAILED tests/test_client.py::test_non_recursion_on_fallback - pystac_client.e...
> FAILED tests/test_client.py::test_fallback_strategy - pystac_client.exception...
> FAILED tests/test_collection_client.py::TestCollectionClient::test_instance
> FAILED tests/test_collection_client.py::TestCollectionClient::test_get_items
> FAILED tests/test_collection_client.py::TestCollectionClient::test_get_items_with_ids
> FAILED tests/test_collection_client.py::TestCollectionClient::test_get_item
> FAILED tests/test_collection_client.py::TestCollectionClient::test_get_item_with_item_search
> FAILED tests/test_collection_client.py::TestCollectionClient::test_get_queryables
> FAILED tests/test_item_search.py::TestItemSearch::test_results - pystac_clien...
> FAILED tests/test_item_search.py::TestItemSearch::test_ids_results - pystac_c...
> FAILED tests/test_item_search.py::TestItemSearch::test_datetime_results - pys...
> FAILED tests/test_item_search.py::TestItemSearch::test_intersects_results - p...
> FAILED tests/test_item_search.py::TestItemSearch::test_result_paging - pystac...
> FAILED tests/test_item_search.py::TestItemSearch::test_result_paging_max_items
> FAILED tests/test_item_search.py::TestItemSearch::test_item_collection - pyst...
> FAILED tests/test_item_search.py::TestItemSearch::test_deprecations[get_item_collections-pages-True-True]
> FAILED tests/test_item_search.py::TestItemSearch::test_deprecations[item_collections-pages-True-True]
> FAILED tests/test_item_search.py::TestItemSearch::test_deprecations[get_items-items-True-True]
> FAILED tests/test_item_search.py::TestItemSearch::test_deprecations[get_all_items-item_collection-False-True]
> FAILED tests/test_item_search.py::TestItemSearch::test_deprecations[get_all_items_as_dict-item_collection_as_dict-False-False]
> FAILED tests/test_item_search.py::TestItemSearch::test_items_as_dicts - pysta...
> FAILED tests/test_item_search.py::TestItemSearchQuery::test_query_shortcut_syntax
> FAILED tests/test_item_search.py::TestItemSearchQuery::test_query_json_syntax
> FAILED tests/test_stac_api_io.py::TestSTAC_IOOverride::test_request_input - p...
> FAILED tests/test_stac_api_io.py::TestSTAC_IOOverride::test_str_input - pysta...
> FAILED tests/test_stac_api_io.py::TestSTAC_IOOverride::test_timeout_smoke_test
> =========== 41 failed, 114 passed, 3 skipped, 1 deselected in 4.39s ============
> E: pybuild pybuild:389: test: plugin pyproject failed with: exit code=1: cd /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11/build; python3.11 -m pytest -k "not test_localized_datetime_converted_to_utc" --block-network
> dh_auto_test: error: pybuild --test --test-pytest -i python{version} -p "3.12 3.11" returned exit code 13
The full build log is available from:
http://qa-logs.debian.net/2024/06/15/pystac-client_0.8.2-1_unstable.log
All bugs filed during this archive rebuild are listed at:
https://bugs.debian.org/cgi-bin/pkgreport.cgi?tag=ftbfs-20240615;users=lucas@debian.org
or:
https://udd.debian.org/bugs/?release=na&merged=ign&fnewerval=7&flastmodval=7&fusertag=only&fusertagtag=ftbfs-20240615&fusertaguser=lucas@debian.org&allbugs=1&cseverity=1&ctags=1&caffected=1#results
A list of current common problems and possible solutions is available at
http://wiki.debian.org/qa.debian.org/FTBFS . You're welcome to contribute!
If you reassign this bug to another package, please mark it as 'affects'-ing
this package. See https://www.debian.org/Bugs/server-control#affects
If you fail to reproduce this, please provide a build log and diff it with mine
so that we can identify if something relevant changed in the meantime.
More information about the Pkg-grass-devel
mailing list