From 3bc5f52236dfb23465e503f0071d7199ddeba723 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Wed, 7 Sep 2022 15:37:35 -0600 Subject: [PATCH 1/2] fix: write_text_to_href The href was not being passed, which broke writing. This popped up when reading an item with pystac-client, modifying it, then writing it to the local filesystem with `save_object`. --- pystac_client/stac_api_io.py | 2 +- tests/test_stac_api_io.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pystac_client/stac_api_io.py b/pystac_client/stac_api_io.py index 316d6bba..279334db 100644 --- a/pystac_client/stac_api_io.py +++ b/pystac_client/stac_api_io.py @@ -151,7 +151,7 @@ def write_text_to_href(self, href: str, *args: Any, **kwargs: Any) -> None: if bool(urlparse(href).scheme): raise APIError("Transactions not supported") else: - return super().write_text_to_href(*args, **kwargs) + return super().write_text_to_href(href, *args, **kwargs) def stac_object_from_dict( self, diff --git a/tests/test_stac_api_io.py b/tests/test_stac_api_io.py index 0c1ce4ee..c09d1080 100644 --- a/tests/test_stac_api_io.py +++ b/tests/test_stac_api_io.py @@ -113,3 +113,11 @@ def test_custom_query_params(self, requests_mock: Mocker) -> None: assert request_qp_name in actual_qp assert len(actual_qp[request_qp_name]) == 1 assert actual_qp[request_qp_name][0] == request_qp_value + + def test_write(self, tmp_path: Path) -> None: + stac_api_io = StacApiIO() + test_file = tmp_path / "test.txt" + stac_api_io.write_text_to_href(str(test_file), "Hi there!") + with open(test_file) as file: + data = file.read() + assert data == "Hi there!" From bd5a082eaf5fe267eac15978e60066c3149e6af2 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Wed, 7 Sep 2022 15:40:15 -0600 Subject: [PATCH 2/2] chore: update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bea2bb87..d2828f11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed - Fix variable name in quickstart example [#316](https://github.com/stac-utils/pystac-client/pull/316) +- `StacApiIO.write_text_to_href` [#312](https://github.com/stac-utils/pystac-client/pull/312) ## Removed