Exemplo n.º 1
0
    def test_item_ext_add_to(self) -> None:
        item = pystac.Item.from_file(self.sentinel_example_uri)
        item.stac_extensions.remove(SatExtension.get_schema_uri())
        self.assertNotIn(SatExtension.get_schema_uri(), item.stac_extensions)

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

        self.assertIn(SatExtension.get_schema_uri(), item.stac_extensions)
Exemplo n.º 2
0
    def test_asset_ext_add_to(self) -> None:
        item = pystac.Item.from_file(self.sentinel_example_uri)
        item.stac_extensions.remove(SatExtension.get_schema_uri())
        self.assertNotIn(SatExtension.get_schema_uri(), item.stac_extensions)
        asset = item.assets["measurement_iw1_vh"]

        _ = SatExtension.ext(asset, add_if_missing=True)

        self.assertIn(SatExtension.get_schema_uri(), item.stac_extensions)
Exemplo n.º 3
0
    def test_summaries_adds_uri(self) -> None:
        col = self.collection()
        col.stac_extensions = []
        self.assertRaisesRegex(
            pystac.ExtensionNotImplemented,
            r"Could not find extension schema URI.*",
            SatExtension.summaries,
            col,
            False,
        )
        _ = SatExtension.summaries(col, True)

        self.assertIn(SatExtension.get_schema_uri(), col.stac_extensions)

        SatExtension.remove_from(col)
        self.assertNotIn(SatExtension.get_schema_uri(), col.stac_extensions)
Exemplo n.º 4
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(SatExtension.get_schema_uri())

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

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

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

        # Should succeed if Asset has no owner
        ownerless_asset = pystac.Asset.from_dict(asset.to_dict())
        _ = SatExtension.ext(ownerless_asset)
Exemplo n.º 5
0
 def test_from_dict(self) -> None:
     orbit_state = sat.OrbitState.GEOSTATIONARY
     relative_orbit = 1001
     d: Dict[str, Any] = {
         "type": "Feature",
         "stac_version": "1.0.0-beta.2",
         "id": "an/asset",
         "properties": {
             "sat:orbit_state": orbit_state.value,
             "sat:relative_orbit": relative_orbit,
             "datetime": "2018-01-02T00:00:00Z",
         },
         "geometry": None,
         "links": [],
         "assets": {},
         "stac_extensions": [SatExtension.get_schema_uri()],
     }
     item = pystac.Item.from_dict(d)
     self.assertEqual(orbit_state, SatExtension.ext(item).orbit_state)
     self.assertEqual(relative_orbit, SatExtension.ext(item).relative_orbit)