Beispiel #1
0
    def test_item_ext_add_to(self) -> None:
        item = pystac.Item.from_file(self.sentinel_example_uri)
        item.stac_extensions.remove(SarExtension.get_schema_uri())
        self.assertNotIn(SarExtension.get_schema_uri(), item.stac_extensions)

        _ = SarExtension.ext(item, add_if_missing=True)

        self.assertIn(SarExtension.get_schema_uri(), item.stac_extensions)
Beispiel #2
0
    def test_extension_not_implemented(self) -> None:
        # Should raise exception if Item does not include extension URI
        item = pystac.Item.from_file(self.sentinel_example_uri)
        item.stac_extensions.remove(SarExtension.get_schema_uri())

        with self.assertRaises(pystac.ExtensionNotImplemented):
            _ = SarExtension.ext(item)

        # Should raise exception if owning Item does not include extension URI
        asset = item.assets["measurement"]

        with self.assertRaises(pystac.ExtensionNotImplemented):
            _ = SarExtension.ext(asset)

        # Should succeed if Asset has no owner
        ownerless_asset = pystac.Asset.from_dict(asset.to_dict())
        _ = SarExtension.ext(ownerless_asset)