Example #1
0
    def test_ext_add_to(self) -> None:
        collection = pystac.Collection.from_file(self.example_collection_uri)
        collection.stac_extensions.remove(ScientificExtension.get_schema_uri())
        self.assertNotIn(ScientificExtension.get_schema_uri(),
                         collection.stac_extensions)

        _ = ScientificExtension.ext(collection, add_if_missing=True)

        self.assertIn(ScientificExtension.get_schema_uri(),
                      collection.stac_extensions)
Example #2
0
    def test_ext_add_to(self) -> None:
        item = pystac.Item.from_file(self.example_item_uri)
        item.stac_extensions.remove(ScientificExtension.get_schema_uri())
        self.assertNotIn(ScientificExtension.get_schema_uri(),
                         item.stac_extensions)

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

        self.assertIn(ScientificExtension.get_schema_uri(),
                      item.stac_extensions)
Example #3
0
    def test_extension_not_implemented(self) -> None:
        # Should raise exception if Collection does not include extension URI
        collection = pystac.Collection.from_file(self.example_collection_uri)
        collection.stac_extensions.remove(ScientificExtension.get_schema_uri())

        with self.assertRaises(pystac.ExtensionNotImplemented):
            _ = ScientificExtension.ext(collection)
Example #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.example_item_uri)
        item.stac_extensions.remove(ScientificExtension.get_schema_uri())

        with self.assertRaises(pystac.ExtensionNotImplemented):
            _ = ScientificExtension.ext(item)
Example #5
0
    def test_summaries_adds_uri(self) -> None:
        collection = self.collection.clone()
        collection.stac_extensions = []
        self.assertRaisesRegex(
            pystac.ExtensionNotImplemented,
            r"Could not find extension schema URI.*",
            ScientificExtension.summaries,
            collection,
            False,
        )
        _ = ScientificExtension.summaries(collection, True)

        self.assertIn(ScientificExtension.get_schema_uri(),
                      collection.stac_extensions)

        ScientificExtension.remove_from(collection)
        self.assertNotIn(ScientificExtension.get_schema_uri(),
                         collection.stac_extensions)