diff --git a/pystac/serialization/migrate.py b/pystac/serialization/migrate.py index 27dd09bec..31b461aac 100644 --- a/pystac/serialization/migrate.py +++ b/pystac/serialization/migrate.py @@ -20,6 +20,7 @@ def _migrate_catalog( d: dict[str, Any], version: STACVersionID, info: STACJSONDescription ) -> None: d["type"] = pystac.STACObjectType.CATALOG + _migrate_license(d) def _migrate_collection_summaries( @@ -38,25 +39,20 @@ def _migrate_collection( d: dict[str, Any], version: STACVersionID, info: STACJSONDescription ) -> None: d["type"] = pystac.STACObjectType.COLLECTION + _migrate_license(d) _migrate_collection_summaries(d, version, info) def _migrate_item( d: dict[str, Any], version: STACVersionID, info: STACJSONDescription ) -> None: - # No migrations necessary for supported STAC versions (>=0.8) - pass + _migrate_license(d["properties"]) -# Extensions -def _migrate_item_assets( - d: dict[str, Any], version: STACVersionID, info: STACJSONDescription -) -> set[str] | None: - if version < "1.0.0-beta.2": - if info.object_type == pystac.STACObjectType.COLLECTION: - if "assets" in d: - d["item_assets"] = d["assets"] - del d["assets"] +def _migrate_license(d: dict[str, Any]) -> None: + if d.get("license") in ["various", "proprietary"]: + d["license"] = "other" + return None @@ -158,11 +154,6 @@ def _get_removed_extension_migrations() -> ( } -# TODO: Item Assets -def _get_extension_renames() -> dict[str, str]: - return {"asset": "item-assets"} - - def migrate_to_latest( json_dict: dict[str, Any], info: STACJSONDescription ) -> dict[str, Any]: diff --git a/tests/data-files/catalogs/cbers-partial/CBERS4AWFI/collection.json b/tests/data-files/catalogs/cbers-partial/CBERS4AWFI/collection.json index fd61437e2..32adb9d65 100644 --- a/tests/data-files/catalogs/cbers-partial/CBERS4AWFI/collection.json +++ b/tests/data-files/catalogs/cbers-partial/CBERS4AWFI/collection.json @@ -16,8 +16,7 @@ } ], "stac_extensions": [ - "https://stac-extensions.github.io/eo/v1.1.0/schema.json", - "https://schemas.stacspec.org/v1.0.0-beta.2/extensions/item-assets/json-schema/schema.json" + "https://stac-extensions.github.io/eo/v1.1.0/schema.json" ], "providers": [ { diff --git a/tests/data-files/catalogs/cbers-partial/CBERS4MUX/collection.json b/tests/data-files/catalogs/cbers-partial/CBERS4MUX/collection.json index 2139aac93..ce858a261 100644 --- a/tests/data-files/catalogs/cbers-partial/CBERS4MUX/collection.json +++ b/tests/data-files/catalogs/cbers-partial/CBERS4MUX/collection.json @@ -16,8 +16,7 @@ } ], "stac_extensions": [ - "https://stac-extensions.github.io/eo/v1.1.0/schema.json", - "https://stac-extensions.github.io/item-assets/v1.0.0/schema.json" + "https://stac-extensions.github.io/eo/v1.1.0/schema.json" ], "providers": [ { diff --git a/tests/data-files/catalogs/cbers-partial/CBERS4PAN10M/collection.json b/tests/data-files/catalogs/cbers-partial/CBERS4PAN10M/collection.json index d33eef2cf..972e5aab3 100644 --- a/tests/data-files/catalogs/cbers-partial/CBERS4PAN10M/collection.json +++ b/tests/data-files/catalogs/cbers-partial/CBERS4PAN10M/collection.json @@ -16,8 +16,7 @@ } ], "stac_extensions": [ - "https://stac-extensions.github.io/eo/v1.1.0/schema.json", - "https://stac-extensions.github.io/item-assets/v1.0.0/schema.json" + "https://stac-extensions.github.io/eo/v1.1.0/schema.json" ], "providers": [ { diff --git a/tests/data-files/catalogs/cbers-partial/CBERS4PAN5M/collection.json b/tests/data-files/catalogs/cbers-partial/CBERS4PAN5M/collection.json index e88f8bb1d..7694f1e8a 100644 --- a/tests/data-files/catalogs/cbers-partial/CBERS4PAN5M/collection.json +++ b/tests/data-files/catalogs/cbers-partial/CBERS4PAN5M/collection.json @@ -16,8 +16,7 @@ } ], "stac_extensions": [ - "https://stac-extensions.github.io/eo/v1.1.0/schema.json", - "https://stac-extensions.github.io/item-assets/v1.0.0/schema.json" + "https://stac-extensions.github.io/eo/v1.1.0/schema.json" ], "providers": [ { diff --git a/tests/data-files/catalogs/test-case-1/country-1/area-1-1/collection.json b/tests/data-files/catalogs/test-case-1/country-1/area-1-1/collection.json index 01cfcbb1e..5bbf0ccc4 100644 --- a/tests/data-files/catalogs/test-case-1/country-1/area-1-1/collection.json +++ b/tests/data-files/catalogs/test-case-1/country-1/area-1-1/collection.json @@ -46,5 +46,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-1/country-1/area-1-2/collection.json b/tests/data-files/catalogs/test-case-1/country-1/area-1-2/collection.json index 83263e698..03c368f5d 100644 --- a/tests/data-files/catalogs/test-case-1/country-1/area-1-2/collection.json +++ b/tests/data-files/catalogs/test-case-1/country-1/area-1-2/collection.json @@ -46,5 +46,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-1/country-2/area-2-1/collection.json b/tests/data-files/catalogs/test-case-1/country-2/area-2-1/collection.json index ccabd5b73..4bb3fd361 100644 --- a/tests/data-files/catalogs/test-case-1/country-2/area-2-1/collection.json +++ b/tests/data-files/catalogs/test-case-1/country-2/area-2-1/collection.json @@ -46,5 +46,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-1/country-2/area-2-2/collection.json b/tests/data-files/catalogs/test-case-1/country-2/area-2-2/collection.json index 165e45580..201b5566d 100644 --- a/tests/data-files/catalogs/test-case-1/country-2/area-2-2/collection.json +++ b/tests/data-files/catalogs/test-case-1/country-2/area-2-2/collection.json @@ -46,5 +46,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/5b922d42-9a77-4f79-a672-86096f7f849e/collection.json b/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/5b922d42-9a77-4f79-a672-86096f7f849e/collection.json index 9e891dd02..9c955c8ca 100644 --- a/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/5b922d42-9a77-4f79-a672-86096f7f849e/collection.json +++ b/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/5b922d42-9a77-4f79-a672-86096f7f849e/collection.json @@ -47,5 +47,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/collection.json b/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/collection.json index fec28f6aa..3ed2b44d3 100644 --- a/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/collection.json +++ b/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/collection.json @@ -53,5 +53,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/f433578c-f879-414d-8101-83142a0a13c3/collection.json b/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/f433578c-f879-414d-8101-83142a0a13c3/collection.json index 2bc1cc53f..958ca390d 100644 --- a/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/f433578c-f879-414d-8101-83142a0a13c3/collection.json +++ b/tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/f433578c-f879-414d-8101-83142a0a13c3/collection.json @@ -47,5 +47,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-4/acc/collection.json b/tests/data-files/catalogs/test-case-4/acc/collection.json index 10cd3bdd5..ec2501de1 100644 --- a/tests/data-files/catalogs/test-case-4/acc/collection.json +++ b/tests/data-files/catalogs/test-case-4/acc/collection.json @@ -76,5 +76,5 @@ ] } }, - "license": "various" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-4/dar/collection.json b/tests/data-files/catalogs/test-case-4/dar/collection.json index 4a253a796..ec37de400 100644 --- a/tests/data-files/catalogs/test-case-4/dar/collection.json +++ b/tests/data-files/catalogs/test-case-4/dar/collection.json @@ -96,5 +96,5 @@ ] } }, - "license": "various" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-4/kam/collection.json b/tests/data-files/catalogs/test-case-4/kam/collection.json index 37c3fef23..4b8845fbe 100644 --- a/tests/data-files/catalogs/test-case-4/kam/collection.json +++ b/tests/data-files/catalogs/test-case-4/kam/collection.json @@ -46,5 +46,5 @@ ] } }, - "license": "various" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-4/mon/collection.json b/tests/data-files/catalogs/test-case-4/mon/collection.json index fd7925393..4641af9d4 100644 --- a/tests/data-files/catalogs/test-case-4/mon/collection.json +++ b/tests/data-files/catalogs/test-case-4/mon/collection.json @@ -76,5 +76,5 @@ ] } }, - "license": "various" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-4/nia/collection.json b/tests/data-files/catalogs/test-case-4/nia/collection.json index 41b70d0de..86399c30e 100644 --- a/tests/data-files/catalogs/test-case-4/nia/collection.json +++ b/tests/data-files/catalogs/test-case-4/nia/collection.json @@ -46,5 +46,5 @@ ] } }, - "license": "various" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/catalogs/test-case-4/ptn/collection.json b/tests/data-files/catalogs/test-case-4/ptn/collection.json index 078ee9690..8fb0edb90 100644 --- a/tests/data-files/catalogs/test-case-4/ptn/collection.json +++ b/tests/data-files/catalogs/test-case-4/ptn/collection.json @@ -56,5 +56,5 @@ ] } }, - "license": "various" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/classification/collection-item-assets-raster-bands.json b/tests/data-files/classification/collection-item-assets-raster-bands.json index cddc7a98c..ea40521a3 100644 --- a/tests/data-files/classification/collection-item-assets-raster-bands.json +++ b/tests/data-files/classification/collection-item-assets-raster-bands.json @@ -110,7 +110,7 @@ ] } }, - "license": "proprietary", + "license": "other", "stac_extensions": [ "https://stac-extensions.github.io/projection/v1.1.0/schema.json", "https://stac-extensions.github.io/eo/v1.1.0/schema.json", diff --git a/tests/data-files/collections/multi-extent.json b/tests/data-files/collections/multi-extent.json index 0ce5f5112..0d8bd351e 100644 --- a/tests/data-files/collections/multi-extent.json +++ b/tests/data-files/collections/multi-extent.json @@ -62,5 +62,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/collections/with-assets.json b/tests/data-files/collections/with-assets.json index cc5ddc481..e3d26ca53 100644 --- a/tests/data-files/collections/with-assets.json +++ b/tests/data-files/collections/with-assets.json @@ -56,5 +56,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/invalid/shared-id/test/collection.json b/tests/data-files/invalid/shared-id/test/collection.json index be31c7996..efd0dc990 100644 --- a/tests/data-files/invalid/shared-id/test/collection.json +++ b/tests/data-files/invalid/shared-id/test/collection.json @@ -41,5 +41,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/item-assets/example-landsat8.json b/tests/data-files/item-assets/example-landsat8.json index 1390bfa7e..237f3bb92 100644 --- a/tests/data-files/item-assets/example-landsat8.json +++ b/tests/data-files/item-assets/example-landsat8.json @@ -1,7 +1,6 @@ { "stac_version": "1.1.0", "stac_extensions": [ - "https://stac-extensions.github.io/item-assets/v1.0.0/schema.json", "eo" ], "type": "Collection", diff --git a/tests/data-files/projection/collection-with-summaries.json b/tests/data-files/projection/collection-with-summaries.json index f471e198d..5510c2a01 100644 --- a/tests/data-files/projection/collection-with-summaries.json +++ b/tests/data-files/projection/collection-with-summaries.json @@ -48,5 +48,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/storage/collection-naip.json b/tests/data-files/storage/collection-naip.json index 174942dc3..c24f38276 100644 --- a/tests/data-files/storage/collection-naip.json +++ b/tests/data-files/storage/collection-naip.json @@ -61,5 +61,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/table/collection-2.json b/tests/data-files/table/collection-2.json index 30dc57b8a..fcae3b117 100644 --- a/tests/data-files/table/collection-2.json +++ b/tests/data-files/table/collection-2.json @@ -5,7 +5,6 @@ "description": "desc", "links": [], "stac_extensions": [ - "https://stac-extensions.github.io/item-assets/v1.0.0/schema.json", "https://stac-extensions.github.io/table/v1.2.0/schema.json" ], "extent": { @@ -28,7 +27,7 @@ ] } }, - "license": "proprietary", + "license": "other", "item_assets": {}, "table:columns": [] } \ No newline at end of file diff --git a/tests/data-files/table/collection.json b/tests/data-files/table/collection.json index 1d0006b29..6e55273cc 100644 --- a/tests/data-files/table/collection.json +++ b/tests/data-files/table/collection.json @@ -1,7 +1,6 @@ { "stac_version": "1.1.0", "stac_extensions": [ - "https://stac-extensions.github.io/item-assets/v1.0.0/schema.json", "https://stac-extensions.github.io/table/v1.2.0/schema.json" ], "type": "Collection", diff --git a/tests/data-files/table/table-collection.json b/tests/data-files/table/table-collection.json index 564d01bd6..e0877c93d 100644 --- a/tests/data-files/table/table-collection.json +++ b/tests/data-files/table/table-collection.json @@ -1,7 +1,6 @@ { "stac_version": "1.1.0", "stac_extensions": [ - "https://stac-extensions.github.io/item-assets/v1.0.0/schema.json", "https://stac-extensions.github.io/table/v1.2.0/schema.json" ], "type": "Collection", diff --git a/tests/data-files/view/collection-with-summaries.json b/tests/data-files/view/collection-with-summaries.json index 87b89d656..2d0acb389 100644 --- a/tests/data-files/view/collection-with-summaries.json +++ b/tests/data-files/view/collection-with-summaries.json @@ -65,5 +65,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/data-files/windows_hrefs/test-collection/collection.json b/tests/data-files/windows_hrefs/test-collection/collection.json index 628c1bf86..6ff742bdc 100644 --- a/tests/data-files/windows_hrefs/test-collection/collection.json +++ b/tests/data-files/windows_hrefs/test-collection/collection.json @@ -40,5 +40,5 @@ ] } }, - "license": "proprietary" + "license": "other" } \ No newline at end of file diff --git a/tests/serialization/test_migrate.py b/tests/serialization/test_migrate.py index 1bc5c4acb..ec1c59c01 100644 --- a/tests/serialization/test_migrate.py +++ b/tests/serialization/test_migrate.py @@ -67,7 +67,7 @@ def test_migrates_added_extension(self) -> None: assert view_ext.sun_elevation, 58.8 assert view_ext.off_nadir, 1 - def test_migrates_renamed_extension(self) -> None: + def test_migrates_removes_extension(self) -> None: collection = pystac.Collection.from_file( TestCases.get_path( "data-files/examples/0.9.0/extensions/asset/" @@ -78,7 +78,8 @@ def test_migrates_renamed_extension(self) -> None: assert ItemAssetsExtension.get_schema_uri() not in collection.stac_extensions assert not ItemAssetsExtension.has_extension(collection) assert "item_assets" in collection.extra_fields - assert collection.item_assets + + assert collection.stac_extensions == [] assert collection.item_assets["thumbnail"].title == "Thumbnail" def test_migrates_pre_1_0_0_rc1_stats_summary(self) -> None: @@ -112,3 +113,19 @@ def test_migrate_works_even_if_stac_extensions_is_null( collection_dict["stac_extensions"] = None pystac.Collection.from_dict(collection_dict, migrate=True) + + +def test_migrate_updates_license_from_various() -> None: + path = TestCases.get_path("data-files/examples/1.0.0/collectionless-item.json") + + item = pystac.Item.from_file(path) + assert item.properties["license"] == "other" + + +def test_migrate_updates_license_from_proprietary() -> None: + path = TestCases.get_path( + "data-files/examples/1.0.0/collection-only/collection.json" + ) + + collection = pystac.Collection.from_file(path) + assert collection.license == "other" diff --git a/tests/test_catalog.py b/tests/test_catalog.py index dfb3db2ed..45b7aa536 100644 --- a/tests/test_catalog.py +++ b/tests/test_catalog.py @@ -1120,7 +1120,7 @@ def test_self_contained_catalog_collection_item_links(self) -> None: spatial=pystac.SpatialExtent([[-180.0, -90.0, 180.0, 90.0]]), temporal=pystac.TemporalExtent([[datetime(2021, 11, 1), None]]), ), - license="proprietary", + license="other", ) item = pystac.Item(