Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,27 @@ def check_all_absolute(cat: Catalog) -> None:
c2.catalog_type = CatalogType.ABSOLUTE_PUBLISHED
check_all_absolute(c2)

def test_self_contained_catalog_collection_item_links(self) -> None:
with tempfile.TemporaryDirectory() as tmp_dir:
cat = TestCases.test_case_9()
cat.normalize_hrefs(tmp_dir)
cat.validate_all()
print(f"Saving catalog to: {tmp_dir}")
cat.save(catalog_type=CatalogType.SELF_CONTAINED)

# read the item back, to make experiment clean
item = Item.from_file(
f"{tmp_dir}/collection-issue-657/item-issue-657/item-issue-657.json"
)
# ensure that all links in the output json are relative
# everything of a nested level > 2 is not relative?
for link in item.links:
href = link.get_href()
self.assertIsNotNone(href)
self.assertFalse(is_absolute_href(href))
# use time sleep to pause there and inspect catalogs manually
# time.sleep(10000)

def test_full_copy_and_normalize_works_with_created_stac(self) -> None:
cat = TestCases.test_case_3()
cat_copy = cat.full_copy()
Expand Down
29 changes: 29 additions & 0 deletions tests/utils/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,32 @@ def test_case_8() -> Collection:
"data-files/catalogs/" "planet-example-v1.0.0-beta.2/collection.json"
)
)

@staticmethod
def test_case_9() -> Catalog:
"""Manually created STAC Catalog, see issue https://github.com/stac-utils/pystac/issues/657"""
catalog = pystac.Catalog(
id="catalog-issue-657", description="catalog-issue-657"
)
collection = pystac.Collection(
"collection-issue-657",
"collection-issue-657",
pystac.Extent(
spatial=pystac.SpatialExtent([[-180.0, -90.0, 180.0, 90.0]]),
temporal=pystac.TemporalExtent([[datetime(2021, 11, 1), None]]),
),
license="proprietary",
)

item = pystac.Item(
id="item-issue-657",
stac_extensions=[],
geometry=ARBITRARY_GEOM,
bbox=ARBITRARY_BBOX,
datetime=datetime(2021, 11, 1),
properties={},
)

collection.add_item(item)
catalog.add_child(collection)
return catalog