Skip to content

Commit

Permalink
fix: don't transform_href in __getstate__ (#1337)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed May 3, 2024
1 parent 3432392 commit 9467ac1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

## [Unreleased]

- Allow object ID as input for getting APILayoutStrategy hrefs and add `items`, `collections`, `search`, `conformance`, `service_desc` and `service_doc` href methods. ([#1335](https://github.com/stac-utils/pystac/pull/1335))
### Fixed

- Don't transform hrefs in `Item.__getstate__` ([#1337](https://github.com/stac-utils/pystac/pull/1337))
- Allow object ID as input for getting APILayoutStrategy hrefs and add `items`, `collections`, `search`, `conformance`, `service_desc` and `service_doc` href methods. ([#1335](https://github.com/stac-utils/pystac/pull/1335))

## [v1.10.0] - 2024-03-28

Expand Down
7 changes: 6 additions & 1 deletion pystac/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ def __getstate__(self) -> dict[str, Any]:
d = self.__dict__.copy()

d["links"] = [
link.to_dict() if link.get_href() else link for link in d["links"]
(
link.to_dict(transform_href=False)
if link.get_href(transform_href=False)
else link
)
for link in d["links"]
]

return d
Expand Down
10 changes: 10 additions & 0 deletions tests/test_item.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import copy
import json
import os
import pickle
Expand Down Expand Up @@ -682,3 +683,12 @@ def test_pickle_with_only_href_links(item: Item) -> None:
assert original.media_type == new.media_type
assert str(original.owner) == str(new.owner)
assert str(original.target) == str(new.target)


def test_copy_with_unresolveable_root(item: Item) -> None:
item.add_link(
pystac.Link(
"root", "s3://naip-visualization/this-is-a-non-existent-catalog.json"
)
)
copy.deepcopy(item)

0 comments on commit 9467ac1

Please sign in to comment.